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.
The standard ATG tag converters are:
Converter | InputDataType | OutputDataType | Function |
---|---|---|---|
| any | any | Throws a form exception if the user specifies a null or empty value |
| String | Date | Parses strings into Dates; displays Dates in a variety of formats |
| Date | Date | Restricts entries to a date range, maximum date, or minimum date. |
| numeric String | integer, float, etc. | Displays numeric data-types in a variety of formats |
| any | any | If field is left empty, corresponding property is set to null |
| numeric String | integer, float, etc. | Determines how a credit card number is displayed |
| numeric string | string | Displays currency in a format appropriate for the locale |
| string | string | Displays a string as formatted HTML text rather than escaped text. |
You can use a subset of tag converters in the context of the following tags: