|< Day Day Up >|| |
Before leaving the Mini HR example, it is necessary to describe the way that execution takes place. As explained in Chapter 1, Struts uses the Model-View-Controller design pattern. The MVC architecture defines a specific flow of execution. An understanding of this flow of execution is crucial to an overall understanding of Struts.
For Mini HR, execution proceeds in the following way:
The browser makes a request to Mini HR for an employee lookup. This request is processed by ActionServlet (Controller).
ActionServlet populates the SearchForm object (View) with the search criteria entered on the search.jsp page.
ActionServlet delegates request-specific processing to the SearchAction object (Controller).
SearchAction (Controller) interfaces with the EmployeeSearchService object (Model) to perform the employee search. EmployeeSearchService returns an ArrayList of Employee objects (Model).
SearchAction (Controller) forwards control to search.jsp (View).
search.jsp (View) uses the ArrayList of Employee objects (Model) to generate a response to the browser.
The flow of execution for Mini HR can be generalized for any Struts application as shown here. Figure 2-6 shows the flow execution in graphic form.
The browser makes a request to the Struts application that is processed by ActionServlet (Controller).
ActionServlet (Controller) populates the ActionForm (View) object with HTML form data and invokes its validate( ) method.
ActionServlet (Controller) executes the Action object (Controller).
Action (Controller) interfaces with model components and prepares data for view.
Action (Controller) forwards control to the JSP (View).
JSP (View) uses model data to generate a response to the browser.
Figure 2-6: Flow of execution
Remember, the same basic pattern of execution applies to any Struts application.
Now that you understand the basic structure of a Struts application and how its components work together, its time to move on to an in-depth examination of Struts. As mentioned at the start, all of the topics presented in this chapter are examined in detail in the chapters that follow.
|< Day Day Up >|| |