Top

NumberField

Review needed

NumberField widget enables the creation of input fields that should contain a numeric value. It also provides formatting facilities to handle numeric and currency patterns.

File /widgets/numberfield/Snippet.tpl
{@aria:NumberField {

  label : "Please enter a decimal number:",
  mandatory : true,
  errorMessages : [ "Please type in a number" ]

}/}

The whole list of configuration parameters is available in NumberFieldCfg bean.

Formatting patterns

You can use formatting patterns to specify how a number should be conventionally displayed, even as a currency. It can be defined as a combination of the following:

Symbol Location Meaning
0 Number Digit
# Number Digit, zero shows as absent
. Number Decimal separator
, Integer Grouping separator
¤ (\u00A4) Prefix or suffix Currency sign, replaced by currency symbol.

The supported patterns are a subset of the java.text.DecimalFormat specs. More information are available at Localization and Resources.

Sample usage

The following sample shows how to create and use a NumberField widget, with a mandatory attribute for error checking and number format patterns. In order to fetch the entered value, variable binding is to be considered as the preferred solution. Please refer to the TextField widget for more informations.

In this sample, the first 3 NumberFields are the same except for the state, which is respectively mandatory, normal and disabled. The fourth NumberField has a pattern, that is used both to interpret and display the number.

More information about the pattern are available at Localization and Resources.

This page was last modified on 19 April 2012, at 15:25 and has been viewed 724 times.