converter - Converter

Defines the data format if it is not string.

Category

data

Syntax

<xp:this.converter>converter</xp:this.converter>
Where converter is one of the following:
<xp:convertBoolean attributes>content</xp:convertBoolean>
<xp:convertNumber attributes>content</xp:convertNumber>
<xp:convertDateTime attributes>content</xp:convertDateTime>
<xp:convertMask attributes>content</xp:convertMask>
<xp:customConverter></xp:customConverter>

Usage

In Design mode, click the Data tab under Properties and look for Display type, or click All Properties and look for converter under data.

Contained properties

Converters have the following properties.
Table 1. Contained properties for boolean conversions
Property Description
loaded="true|false"
Whether to create a tag instance at page load. Defaults to true.
message="message text"
Message for the user if strict="true" and the user enters a value other than true or false. The message appears at data submission time.
strict="true|false"
If true, accepts only the input values true and false. By default, any input value other than true is considered false.
Table 2. Contained properties for numeric conversions
Property Description
currencyCode="option"
ISO 4712 currency code, for example, USD.
currencySymbol="symbol"
Currency symbol.
groupingUsed="true|false"
Whether "grouping separators" are used. Defaults to true.
integerOnly="true|false"
Whether the value is truncated to an integer. Defaults to false.
loaded="true|false"
Whether to create a tag instance at page load. Defaults to true.
locale="option"
A language and country code, for example, en_US.
maxFractionDigits="n"
Maximum digits in the fractional part of a number.
maxIntegerDigits="n"
Maximum digits in the integer part of a number.
minFractionDigits="n"
Minimum digits in the fractional part of a number.
minIntegerDigits="n"
Minimum digits in the integer part of a number.
pattern="pattern"
User-defined pattern for formatting the converted number value.
type="number|currency|percent"
Formatting for conversion. Defaults to number.
Table 3. Contained properties for date/time conversions
Property Description
dateStyle="default|short|medium|long|full"
Predefined formatting for a date value.
ignoreUserTimeZone="true|false"
Whether to ignore the user time zone in favor of the platform time zone.
loaded="true|false"
Whether to create a tag instance at page load. Defaults to true.
locale="option"
A language and country code, for example, en_US.
pattern="pattern"
User-defined pattern for formatting the converted date-time value.
timeStyle="default|short|medium|long|full"
Predefined formatting for a time value.
timeZone="option"
Time zone for formatted value, for example, US/Eastern.
type="date|time|both"
Which part or parts to format. Defaults date.
Table 4. Contained properties for mask conversions
Property Description
asis="true|false"
Whether to remove data other than masked input. Defaults to false.
loaded="true|false"
Whether to create a tag instance at page load. Defaults to true.
mask="mask"
Mask characters where # is a digit placeholder and ? is a letter placeholder.

Examples

This Edit Box converts its associated data to a number.
<xp:inputText id="inputText1" value="#{document1.quantity}">
	<xp:this.converter>
		<xp:convertNumber type="number"></xp:convertNumber>
	</xp:this.converter>
</xp:inputText>
This Edit Box converts its associated data to a boolean value.
<xp:inputText id="inputText1" value="#{document1.ispublic}">
	<xp:this.converter>
		<xp:convertBoolean" strict="true" message="Enter true or false for ispublic"></xp:convertBoolean>
	</xp:this.converter>
</xp:inputText>