It is not surprising that ActionForm
class is called before Action
- Struts form should be filled with user's data before calling of Struts action method, any of which has 4 parameters:
ActionMapping actionMapping,
ActionForm actionForm,
HttpServletRequest request,
HttpServletResponse response
Second one - ActionForm
- should be ready to allow furthest data processing. I've just found great sequence diagram to illustrate all Struts lifecycle stages:
In short:
- After getting client's request Struts front-controller calls
RequestProcessor
to find out appropriate action and form using struts-config.xml RequestProcessor
gets Struts form object (or creates it if it doesn't exist), populates with data from request, initiates validation (if exists) and calls appropriate Struts action.- Struts action performs all furthers necessary operations.