org.apache.tapestry.form.translator
Class NumberTranslator

java.lang.Object
  extended byorg.apache.tapestry.form.AbstractFormComponentContributor
      extended byorg.apache.tapestry.form.translator.AbstractTranslator
          extended byorg.apache.tapestry.form.translator.FormatTranslator
              extended byorg.apache.tapestry.form.translator.NumberTranslator
All Implemented Interfaces:
FormComponentContributor, Translator

public class NumberTranslator
extends FormatTranslator

A DecimalFormat-based Translator implementation.

Since:
4.0
Author:
Paul Ferraro

Constructor Summary
NumberTranslator()
           
NumberTranslator(java.lang.String initializer)
           
 
Method Summary
protected  java.lang.String defaultPattern()
           
protected  java.lang.String defaultScript()
          Defines the default JavaScript file used by this contributor.
protected  java.lang.String formatObject(IFormComponent field, java.util.Locale locale, java.lang.Object object)
           
protected  ValidationConstraint getConstraint()
           
 java.text.DecimalFormat getDecimalFormat(java.util.Locale locale)
           
protected  java.text.Format getFormat(java.util.Locale locale)
           
protected  java.lang.String getMessageKey()
           
protected  java.lang.Object[] getMessageParameters(java.util.Locale locale, java.lang.String label)
           
 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 setOmitZero(boolean omitZero)
          If true (which is the default for the property), then values that are 0 are rendered to an empty string, not "0" or "0.00".
 
Methods inherited from class org.apache.tapestry.form.translator.FormatTranslator
getPattern, parseText, setPattern
 
Methods inherited from class org.apache.tapestry.form.translator.AbstractTranslator
buildMessage, format, getMessage, getValueForEmptyInput, isTrim, parse, setMessage, setTrim
 
Methods inherited from class org.apache.tapestry.form.AbstractFormComponentContributor
getScript, setScript
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumberTranslator

public NumberTranslator()

NumberTranslator

public NumberTranslator(java.lang.String initializer)
Method Detail

formatObject

protected java.lang.String formatObject(IFormComponent field,
                                        java.util.Locale locale,
                                        java.lang.Object object)
Overrides:
formatObject in class FormatTranslator
See Also:
AbstractTranslator.formatObject(org.apache.tapestry.form.IFormComponent, Locale, java.lang.Object)

defaultScript

protected java.lang.String defaultScript()
Description copied from class: AbstractFormComponentContributor
Defines the default JavaScript file used by this contributor. Overriden by most subclasses that use JavaScript.

Overrides:
defaultScript in class AbstractFormComponentContributor
See Also:
AbstractFormComponentContributor.defaultScript()

defaultPattern

protected java.lang.String defaultPattern()
Specified by:
defaultPattern in class FormatTranslator
See Also:
FormatTranslator.defaultPattern()

getFormat

protected java.text.Format getFormat(java.util.Locale locale)
Specified by:
getFormat in class FormatTranslator
See Also:
FormatTranslator.getFormat(java.util.Locale)

getDecimalFormat

public java.text.DecimalFormat getDecimalFormat(java.util.Locale locale)

getMessageKey

protected java.lang.String getMessageKey()
Specified by:
getMessageKey in class FormatTranslator
See Also:
FormatTranslator.getMessageKey()

getMessageParameters

protected java.lang.Object[] getMessageParameters(java.util.Locale locale,
                                                  java.lang.String label)
Overrides:
getMessageParameters in class AbstractTranslator
See Also:
AbstractTranslator.getMessageParameters(java.util.Locale, java.lang.String)

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 AbstractTranslator
See Also:
FormComponentContributor.renderContribution(org.apache.tapestry.IMarkupWriter, org.apache.tapestry.IRequestCycle, FormComponentContributorContext, org.apache.tapestry.form.IFormComponent)

getConstraint

protected ValidationConstraint getConstraint()
Specified by:
getConstraint in class FormatTranslator
See Also:
FormatTranslator.getConstraint()

setOmitZero

public void setOmitZero(boolean omitZero)
If true (which is the default for the property), then values that are 0 are rendered to an empty string, not "0" or "0.00". This is useful in most cases where the field is optional; it allow the field to render blank when no value is present.