Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Type conversion is great for situations where you need to turn a String in to a more complex object. Because the web is type-agnostic (everything is a String in HTTP), WebWork's type conversion features are very useful. For instance, if you were prompting a user to enter in coordinates in the form of a String ("3, 22"), you could have WebWork do the conversion both from String to Point and from Point to String.

Panel
bgColor#ffffce

(info) Conversion errors happen all the time (a user enters an invalid date, for example). WebWork handles these through XWork's type conversion error handling.

Using this "point" example, if your action (or another compound object in which you are setting properties on) has a corresponding className-conversion.properties file, WebWork will use the configured type converters for conversion to and from strings. So turning "3, 22" in to new Point(3, 22) is done by merely adding the following entry to ClassName-conversion.properties:

...