Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: More explanation for adding to beans and application-wide

...

Within the conversion file, name the action's property and the Converter to apply to it:

Code Block
# syntax: <propertyName> = <converterClassName>
point = com.acme.PointConverter 
person.phoneNumber = com.acme.PhoneNumberConverter

Type conversion can also be specified via Annotations within the action.

Applying a Type Converter to a bean or model

When getting or setting the property of a bean, the framework will look for "classname-conversion.properties" in the same location of the classpath as the target bean. This is the same mechanism as used for actions.

Applying a Type Converter for an application

Application-wide converters can be specified in a file called xwork-converters.properties located in the root of the classpath.

Code Block

# syntax: <type> = <converterClassName>
java.math.BigDecimal = com.acme.MyBigDecimalConverter 

A Simple Example

Wiki Markup
{snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork2.conversion.impl.XWorkConverter}

...