# <af:convertNumber>

af:convertNumber convertNumber convert number

type: oracle.adf.rich.Number

This is an extension of the standard JSF javax.faces.convert.NumberConverter The converter provides all the standard functionality of the default NumberConverter and is strict while converting to object.

JSF javax.faces.convert.NumberConverter will convert values like 22.22.2 or 22ABC to valid Number 22.22 and 22 respectively. Here it would result in a conversion failure and would throw a ConverterException.

If `number grouping separator, decimal separator` is configured in `trinidad-config.xml` file, it will be used during call to `getAsObject()` and `getAsString()` for parsing and formatting. If it has not been set, `number grouping separator, decimal separator` is defaulted based on the locale.

If `currencyCode` is set on the converter then it will be used. Else uses the `currencyCode` set in `trinidad-config.xml` file. If it is not set in the configuration file then it is defaulted based on the locale.

Since ADF Faces is compatible with JDK 1.4 and higher versions, the `currencyCode` gets preference over `currencySymbol.` See JSF's javax.faces.convert.NumberConverter for the way in which `currencyCode` and `currencySymbol` gets preference for different version of JDK.

This converter is automatically registered under the standard converter ID, and therefore will be used when the `<f:convertNumber>` tag is used.

This converter also runs on the client (implements org.apache.myfaces.trinidad.convert.ClientConverter). The converter performs number formatting, parsing and conversions on the fly within the browser thereby eliminating the need to perform a server round-trip for formatting input numbers. However, client conversion is skipped in the following situations:

- If the `pattern` attribute is specified. The converter will only run on the server.
- If the input string contains more than 15 digits, which is the maximum precision supported by JavaScript number. The converter will only run on the server.

For more information see javadoc for `org.apache.myfaces.trinidad.convert.NumberConverter`

## Attributes

Name | Type | Supports EL? | Description
currencyCode | String | Yes | The ISO 4217 currency code, applied only when formatting currencies. Currency code can also be set for the entire application in trinidad-config.xml file. If currency code is not set on the converter, and if set on trinidad-config.xml configuration file it will be used by calling `AdfFacesContext().getCurrenctInstance().getCurrencyCode().` This currency code will be used during call to getAsString() for formatting, provided type is set to 'currency'.
currencySymbol | String | Yes | Currency symbol, is applied only when formatting currencies (i.e. type is set to 'currency'). If currency code is set then symbol will be ignored.
disabled | boolean | Yes | Default Value: false Whether the converter should be disabled, default to false.
groupingUsed | boolean | Yes | Default Value: true Flag specifying whether formatted output will contain grouping separators. Default value is true.
hintPattern | String | Yes | Custom hint message to be used, instead of the default one to give a hint on the desired pattern. Parameters: {0} the pattern the converter is expecting
integerOnly | boolean | Yes | Default Value: false Flag specifying whether only the integer part of the value will be formatted and parsed. Default value is false.
locale | java.util.Locale | Yes | Locale whose predefined styles for dates and times are used during formatting or parsing. If not specified or if null, the Locale returned by RequestContext.getFormattingLocale() will be used. If that is null, FacesContext.getViewRoot().getLocale() will be used.
maxFractionDigits | int | Yes | Default Value: 3 Maximum number of digits that will be formatted in the fractional portion of the output. The default value of 3 is standard JSF behavior.
maxIntegerDigits | int | Yes | Maximum number of digits that will be formatted in the integer portion of the output.
messageDetailConvertCurrency | String | Yes | Custom error message to be used, for creating detail part of the `FacesMessage`, when `value` cannot be converted to a number, when `type` is set to `'currency'` and `pattern` is null or not set. Parameters: {0} the label that identifies the component {1} value entered by the user Please note: Parameter {1} which specifies the value entered by the user, should never be used in the message if the value is secure, like when secret=true on inputText.
messageDetailConvertNumber | String | Yes | Custom error message to be used, for creating detail part of the `FacesMessage`, when `value` cannot be converted to a number, when `type` is set to `'number'` and `pattern` is null or not set. Parameters: {0} the label that identifies the component {1} value entered by the user Please note: Parameter {1} which specifies the value entered by the user, should never be used in the message if the value is secure, like when secret=true on inputText.
messageDetailConvertPattern | String | Yes | Custom error message to be used, for creating detail part of the `FacesMessage` message, when `value` cannot be converted to a number, based on the `pattern` set. Parameters: {0} the label that identifies the component {1} value entered by the user {2} the specified conversion pattern Please note: Parameter {1} which specifies the value entered by the user, should never be used in the message if the value is secure, like when secret=true on inputText.
messageDetailConvertPercent | String | Yes | Custom error message to be used, for creating detail part of the `FacesMessage`, when `value` cannot be converted to a number, when `type` is set to `'percent'` and `pattern` is null or not set. Parameters: {0} the label that identifies the component {1} value entered by the user Please note: Parameter {1} which specifies the value entered by the user, should never be used in the message if the value is secure, like when secret=true on inputText.
minFractionDigits | int | Yes | Minimum number of digits that will be formatted in the fractional portion of the output. Although there is no upper bound on the minimum fraction digits, it is recommended to restrict within 16, since JavaScript numbers are stored in 64-bit IEEE-754 format.
minIntegerDigits | int | Yes | Minimum number of digits that will be formatted in the integer portion of the output.
negativePrefix | String | Yes | Specifies the negative prefix, to be applied only when formatting negative numbers. Negative prefix specified using the this attribute is enforced on the client as well, a benefit not available when the same is enforced using the 'pattern' attribute, which is server only. Negative prefix specified through 'negativePrefix' attribute will override any negative prefix implied using the pattern attribute.
negativeSuffix | String | Yes | Specifies the negative suffix, to be applied only when formatting negative numbers. Negative suffix specified using the this attribute is enforced on the client as well, a benefit not available when the same is enforced using the 'pattern' attribute, which is server only. Negative suffix specified through 'negativeSuffix' attribute will override any negative suffix implied using the pattern attribute.
pattern | String | Yes | Custom formatting pattern which determines how the number string should be formatted and parsed. Valid values are those supported by java.text.DecimalFormat. If specified, the converter will be run on the server, as this attribute is not supported on the client.
roundingMode | java.math.RoundingMode | Yes | Specifies how numbers will be rounded. Default value is the JDK default for NumberFormat, usually RoundingMode.HALF_EVEN.
type | String | Yes | Default Value: number Specifies how the number string will be formatted and parsed. Valid values are "number", "currency", and "percent". Default value is "number".