To enable more control over data conversions, the ATG platform provides tag converter classes. Tag converters let you specify how data in forms is interpreted and displayed, and to control when exceptions are thrown. You specify tag converters through special attributes that ATG provides.

For example, your form might have the following field:

<dsp:input type="text" bean="MyBean.age"/>

The tag in this example creates a text input field whose value is used to set the value of the age property of the MyBean component on form submission. The ATG platform sets this property by calling setAge() for the class that is an instance of MyBean.

Because the age property has a data type of int, the user-supplied value must be converted from a string before the call to setAge(). Thus, if the user enters 26, the text string 26 is converted to int 26. However, if the user enters a string value such as Hello, the conversion fails and an exception is thrown.

You can specify tag converters in the following DSP tags:

dsp:a
dsp:input
dsp:param
dsp:postfield
dsp:select
dsp:setvalue
dsp:textarea
dsp:valueof

Explicit conversion

You can invoke a tag converter explicitly with the following syntax:

<tag-name bean="property-spec" converter="converter-nameconverter-name="format">

For example:

<dsp:input bean="Seminar.startDate" converter="date" date="M/dd/yyyy"/>

Implicit conversion

A tag can omit the converter attribute and implicitly invoke a tag converter by specifying only the converter name and format. In the following example, the dsp:input tag implicitly invokes the date converter:

<dsp:input bean="Seminar.startDate" date="M/dd/yyyy"/>

The following table lists the standard ATG tag converters:

Converter

Inputdatatype

Outputdatatype

Function

creditCard

numeric string

integer, float, etc.

Determines how a credit card number is displayed.

currency
currencyConversion
euro

numeric string

string

Displays currency in a format appropriate for the locale

date

String

Date

Parses strings into Dates; displays Dates in a variety of formats.

map

Map

Map

Ensures that key-value pairs are parsed correctly for the specified map property.

nullable

any

any

If field is left empty, corresponding property is set to null

number

numeric string

integer, float, etc.

Displays numeric data-types in a variety of formats

required

any

any

Throws a form exception if the user specifies a null or empty value

valueishtml

string

string

Displays a string as formatted HTML text rather than escaped text.

The following sections discuss tag converters in greater detail.

 
loading table of contents...