Versions Compared

Key

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

Excerpt
hiddentrue

Struts ActionForms


ActionForms can be stored in either the request (preferable) or session (default) or request scope. If they're in the session scope it's important to implement the form's reset method to initialize the form before each use. ActionForms should be request based unless they are carried across more than one page, e.g. as in a page using search help. Need code example with reset method..as is the case for our mortar ActionForm, SearchHelpParamsForm used in all or our apps with action path /SearchHelpNavAction (see struts-config). But 99% of all others should be request scope.

By definition, every ActionForm must be a subclass of org.apache.struts.action.ActionForm. 

Most of the time, you should be able to stuff biz objects directly into a ActionForm (and not flatten them out; i.e. you don't need to create fields in the form for each field in the biz object). Struts is able to deal with populating and returning nested objects. For example, you might have a "customer" bean on your ActionForm, and then refer to the property "customer.name" in your presentation page. This would correspond to the methods customer.getName() and customer.setName(String Name) on your customer bean. See the Apache Struts Taglib Developer Guides for more about using the nested syntax.

...