WebWork has one of the most advanced type conversion abilities in any web-based framework in any Java language. Generally, you don't need to do anything to take advantage of it, other than name your HTML inputs (form elements and other GET/POST parameters) names that are valid OGNL expressions.
A Simple Example
WebWork ships with a helper base class that makes converting to and from Strings very easy. The class is com.opensymphony.webwork.util.WebWorkTypeConverter. This class makes it very easy for you to write type converters that handle converting objects to Strings as well as from Strings. From the JavaDocs for this class:
Built in Type Conversion Support
Relationship to Parameter Names
Advanced Type Conversion
Null Property Handling
Collection and Map Support
Type Conversion Error Handling
There are two ways the error reporting can occur:
- globally, using the Conversion Error Interceptor
- on a per-field basis, using the Conversion Field Validator
By default, the conversion interceptor is included in webwork-default.xml in the default stack, so if you don't want conversion errors reporting globally, you'll need to change the interceptor stack and add additional validation rules.