Saturday, August 26, 2006

MVC Framework wrt Struts...

MVC ( Model View Controller ) is framework which is used in web application design. It had been used for years to get the structure in place. Apache struts has been popular in this regards.

In any web based application, the flow is very simple, User puts in request and the request goes to back end ( over HTTP port 80), Where the flow of the applicaiton is controlled by controller ( ActionServlet in case of struts to map the Action to be taken with the input request ( jsp page )) and being redirected to vie view ( jsp ( this assembles the data populated POJO objects from the back end to show thre results ). View are jsp pages which has been redirected by the controller on having done the action ( Action are the classes in struts written by the user to do back end code processing ).

Model are the action class which talks to the back end ( esp distributed transactionally controlled modules like EJB, HiberNate, or legacy applications )

In a way Struts used many a tag libraries to help write view code. Tag Libraries are precompiled java classes to generate HTML Form elements. Struts also comes with pluggable validation ( esp javascript in the form of xml file )and plugin configuration facility.

Silent features of struts...
1) ActionServlet reads the struts-config.xml to load and map the workflow by means of action tags.
2) ActionForm are the inputs taken from the page and sent in the form of POJO to the back end Action classes. These forms have reset and validation methods to modify data.
3) Action classes created use command pattern to use request ( with Forms, Mapping, etc ) to process request and send response.

No comments: