Quantcast
Channel: Making Life Simple » struts
Viewing all articles
Browse latest Browse all 3

ActionForm – Reset multiple list

0
0

Struts uses ActionForm to both populate a HTML form, and then to capture the parameters when a form is submitted.

When a request is submitted, the ActionServlet matches the URI for the request against the path of an action-mapping. If there is a form-bean for that action-mapping, it looks for an ActionForm under the form-bean name. If it doesn’t find one, a new one is created. The ActionServlet then calls reset() on the new or pre-existing ActionForm and populates it from the request. If the action-mapping has validate set to true, the ActionServlet calls the validate method. If this returns any error messages, the ActionServlet forwards to the URI indicated by the action-mappings error property. This is often a JSP, but it can also be another action-mapping. The latter being needed when there are drop-down controls to populate and so forth. If there are no errors, the ActionServlet passes the (populated and validated) ActionForm to the Action indicated by the action-mapping element.

If you have a form with say a multiple select list, when you unselect items from the list and submit, the ActionForm class would not empty the collection. The easy way to fix it is by writing your own reset() method in which you simply initialize or empty the collection.


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images