Class NumericTranslatorSupportImpl
java.lang.Object
org.apache.tapestry5.internal.translator.NumericTranslatorSupportImpl
- All Implemented Interfaces:
NumericTranslatorSupport
-
Constructor Summary
ConstructorsConstructorDescriptionNumericTranslatorSupportImpl(TypeCoercer typeCoercer, ThreadLocale threadLocale, JavaScriptSupport javascriptSupport) -
Method Summary
Modifier and TypeMethodDescriptiongetMessageKey(Class<T> type) Returns the default message key for parse failures for the indicated type.<T extends Number>
TparseClient(Class<T> type, String clientValue) Parses a client-submitted value in a localized manner.<T extends Number>
voidsetupTranslation(Class<T> type, Element element, String message) Adds client-side format validation for the field, appropriate to the indicated type.Converts a server-side value to a client-side string.
-
Constructor Details
-
NumericTranslatorSupportImpl
public NumericTranslatorSupportImpl(TypeCoercer typeCoercer, ThreadLocale threadLocale, JavaScriptSupport javascriptSupport)
-
-
Method Details
-
setupTranslation
Description copied from interface:NumericTranslatorSupportAdds client-side format validation for the field, appropriate to the indicated type.- Specified by:
setupTranslationin interfaceNumericTranslatorSupport- Parameters:
type- value typemessage- message if the client-side value can't be parsed as a number
-
parseClient
Description copied from interface:NumericTranslatorSupportParses a client-submitted value in a localized manner.- Specified by:
parseClientin interfaceNumericTranslatorSupport- Parameters:
type- desired type of valueclientValue- value from client; this will be trimmed of leading/trailing whitespace- Returns:
- the parsed value
- Throws:
ParseException- See Also:
-
toClient
Description copied from interface:NumericTranslatorSupportConverts a server-side value to a client-side string. Integer types are formatted simply; decimal types may be formatted using thousands-seperator commas.- Specified by:
toClientin interfaceNumericTranslatorSupport- Parameters:
type- type of value to convertvalue- current (non-null) value- Returns:
- value formatted
-
getMessageKey
Description copied from interface:NumericTranslatorSupportReturns the default message key for parse failures for the indicated type.- Specified by:
getMessageKeyin interfaceNumericTranslatorSupport- Returns:
- a message key: either "integer-format-exception" or "number-format-exception"
-