...
Relationship to Parameter Names
The best way to take advantage of WebWork's type conversion is to utilize complete objects (ideally your domain objects directly), rather than submitting form values on to intermediate primitives and strings in your action and then converting those values to full objects in the execute() method. Some tips for achieving this are:
- Use complex OGNL expressions - WebWork will automatically take care of creating the actual objects for you.
- Use JavaBeans! WebWork can only create objects for you if your objects obey the JavaBean specification and provide no-arg constructions, as well as getters and setters where appropriate.
- Remember that person.name will call getPerson().setName(), but if you are expecting WebWork to create the Person object for you, a setPerson() must also exist.
- For lists and maps, use index notation, such as people0.name or friends'patrick'.name. Often these HTML form elements are being rendered inside a loop, so you can use the iterator tag's status attribute if you're using JSP Tags or the ${foo_index} special property if you're using FreeMarker Tags.
- FOr multiple select boxes, you obviously can't name each individual item using index notation. Instead, name your element simply people.name and WebWork will understand that it should create a new Person object for each selected item and set it's name accordingly.
Advanced Type Conversion
Null Property Handling
...