Wednesday, July 20, 2011

Struts - Key tips for my reference

View
[ Present info to user. Accept inputs from user ]

 |
\|/
 ActionServlet                           
[ Intercepts the URL and maps it with struts configuration file ] 
                           
 |                          
\|/                        
                           
Action                  

 |
\|/

Model Layer
[Interfaces to database, etc]

Process Flow:

1. At startup, web.xml is loaded by container, which inturn loads the ActionServlet and struts-config.xml.
2. When a request comes to the container, the container sends the request to the ActionServlet.
3. The ActionServlet looksup for the corresponding action class from the struts-config.xml and sends the request to the corresponding action class.
4. The Action class communicates with the model objects and performs the functionalities.
5. The Action class returns the response to ActionServlet and the view is rendered to the user.
  • ActionForm = Form bean in java with validation(), reset() methods
    • DynaActionForm = Moves the same to xml. No java bean is required. But validation has to be done on the action class.
      • DynaValidatorForm = Same as DynaActionForm, but validation can be done by configuring on the xml itself.
      • DynaValidatorActionForm = Same as DynaValidatorForm, but instead of referring the form bean name, the action name is referred for validation.

  • ValidatorForm = Java bean with XML style validation.
    • ValidatorActionForm = Same as Validator Form, but instead of referring the form bean name, the action name is referred for validation.


  • Action classes are created only once per web application

No comments:

Post a Comment