org.apache.tapestry.form.translator
Class AbstractTranslator
java.lang.Object
org.apache.tapestry.form.AbstractFormComponentContributor
org.apache.tapestry.form.translator.AbstractTranslator
- All Implemented Interfaces:
- FormComponentContributor, Translator
- Direct Known Subclasses:
- FormatTranslator, StringTranslator
public abstract class AbstractTranslator
- extends AbstractFormComponentContributor
- implements Translator
Abstract Translator
implementation that provides default behavior for trimming, null
object, and empty text handling.
- Since:
- 4.0
- Author:
- Paul Ferraro
Method Summary |
protected java.lang.String |
buildMessage(ValidationMessages messages,
IFormComponent field,
java.lang.String key)
|
java.lang.String |
format(IFormComponent field,
java.util.Locale locale,
java.lang.Object object)
Invoked during rendering to format an object (which may be null) into a text value (which
should not be null) appropriate for the specified field. |
protected abstract java.lang.String |
formatObject(IFormComponent field,
java.util.Locale locale,
java.lang.Object object)
|
protected java.lang.Object |
getEmpty()
|
java.lang.String |
getMessage()
|
protected java.lang.Object[] |
getMessageParameters(java.util.Locale locale,
java.lang.String label)
|
boolean |
isTrim()
|
java.lang.Object |
parse(IFormComponent field,
ValidationMessages messages,
java.lang.String text)
Invoked during rewind to parse a submitted input value into an object suitable for the
specified component. |
protected abstract java.lang.Object |
parseText(IFormComponent field,
ValidationMessages messages,
java.lang.String text)
|
void |
renderContribution(IMarkupWriter writer,
IRequestCycle cycle,
FormComponentContributorContext context,
IFormComponent field)
Invoked by a form component after it finishes rendering its tag (but before the tag is
closed) to allow this object to contribute to the component's rendering process. |
void |
setMessage(java.lang.String message)
|
void |
setTrim(boolean trim)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AbstractTranslator
public AbstractTranslator()
AbstractTranslator
public AbstractTranslator(java.lang.String initializer)
format
public java.lang.String format(IFormComponent field,
java.util.Locale locale,
java.lang.Object object)
- Description copied from interface:
Translator
- Invoked during rendering to format an object (which may be null) into a text value (which
should not be null) appropriate for the specified field.
- Specified by:
format
in interface Translator
locale
- TODO- See Also:
Translator.format(org.apache.tapestry.form.IFormComponent,
Locale, java.lang.Object)
parse
public java.lang.Object parse(IFormComponent field,
ValidationMessages messages,
java.lang.String text)
throws ValidatorException
- Description copied from interface:
Translator
- Invoked during rewind to parse a submitted input value into an object suitable for the
specified component.
- Specified by:
parse
in interface Translator
messages
- TODO
- Returns:
- the parsed object
- Throws:
ValidatorException
- if the specified text could not be parsed into an object.- See Also:
Translator.parse(org.apache.tapestry.form.IFormComponent,
ValidationMessages, java.lang.String)
formatObject
protected abstract java.lang.String formatObject(IFormComponent field,
java.util.Locale locale,
java.lang.Object object)
parseText
protected abstract java.lang.Object parseText(IFormComponent field,
ValidationMessages messages,
java.lang.String text)
throws ValidatorException
- Throws:
ValidatorException
getEmpty
protected java.lang.Object getEmpty()
buildMessage
protected java.lang.String buildMessage(ValidationMessages messages,
IFormComponent field,
java.lang.String key)
getMessageParameters
protected java.lang.Object[] getMessageParameters(java.util.Locale locale,
java.lang.String label)
renderContribution
public void renderContribution(IMarkupWriter writer,
IRequestCycle cycle,
FormComponentContributorContext context,
IFormComponent field)
- Description copied from interface:
FormComponentContributor
- Invoked by a form component after it finishes rendering its tag (but before the tag is
closed) to allow this object to contribute to the component's rendering process. Typically
used by Validators and Translators to add javascript methods to the form's submit event
handler.
- Specified by:
renderContribution
in interface FormComponentContributor
- Overrides:
renderContribution
in class AbstractFormComponentContributor
- Parameters:
writer
- allows contributor to write additional attributes into the component's tagcycle
- for accessing request informationcontext
- utilities for genering messages and client-side validationfield
- the field for which contributions are being rendered- See Also:
org.apache.tapestry.form.FormComponentContributor#renderContribution(org.apache.tapestry.IRequestCycle,
org.apache.tapestry.form.IFormComponent)
isTrim
public boolean isTrim()
setTrim
public void setTrim(boolean trim)
getMessage
public java.lang.String getMessage()
setMessage
public void setMessage(java.lang.String message)