You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 13 Next »

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

Error formatting macro: snippet: java.lang.NullPointerException
Error formatting macro: snippet: java.lang.NullPointerException

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:

Error formatting macro: snippet: java.lang.NullPointerException

Built in Type Conversion Support

Error formatting macro: snippet: java.lang.NullPointerException

Relationship to Parameter Names

Advanced Type Conversion

Null Property Handling

Error formatting macro: snippet: java.lang.NullPointerException
Error formatting macro: snippet: java.lang.NullPointerException

Collection and Map Support

Type Conversion Error Handling

Error formatting macro: snippet: java.lang.NullPointerException

There are two ways the error reporting can occur:

  1. globally, using the Conversion Error Interceptor
  2. 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.

  • No labels