Chapter 2: Struts Framework Components


In this chapter:

  1. You will learn more about Struts components and their categories ‚ Controller and View

  2. You will understand the sequence of events in Struts request handling lifecycle

  3. You will understand the role of the following controller classes - ActionServlet, RequestProcessor, ActionForm, Action, ActionMapping and ActionForward in the request handling lifecycle

  4. You will also learn about the role of Struts Tags as View components in rendering the response

  5. You will understand the various elements of Struts configuration file ‚ struts-config.xml

In the last chapter, you had a cursory glance at the Struts framework. In this chapter you will dive deeper and cover various Struts Framework Components. Here is something to remember all the time.

  1. All the core components of Struts framework belong to Controller category.

  2. Struts has no components in the Model category.

  3. Struts has only auxiliary components in View category. A collection of custom tags making it easy to interact with the controller. The View category is neither the core of Struts framework nor is it necessary. However it is a helpful library for using Struts effectively in JSP based rendering.

Controller Category: The ActionServlet and the collaborating classes form the controller and is the core of the framework. The collaborating classes are RequestProcessor , ActionForm , Action , ActionMapping and ActionForward .

View Category: The View category contains utility classes ‚ variety of custom tags making it easy to interact with the controller. It is not mandatory to use these utility classes. You can replace it with classes of your own. However when using Struts Framework with JSP, you will be reinventing the wheel by writing custom tags that mimic Struts view components. If you are using Struts with Cocoon or Velocity, then have to roll out your own classes for the View category.

Model Category: Struts does not offer any components in the Model Category. You are on you own in this turf. This is probably how it should be. Many component models (CORBA, EJB) are available to implement the business tier . Your model components are as unique as your business and should not have any dependency on a presentation framework like Struts. This philosophy of limiting the framework to what is absolutely essential and helpful and nothing more has prevented bloating and made the Struts framework generic and reusable.

Note ‚  

Some people argue that ActionForm is the model component. However ActionForm is really part of the controller. The Struts documentation also speaks along similar lines. It is just View Data Transfer Object ‚ a regular JavaBeans that has dependencies on the Struts classes and used for transferring the data to various classes within the controller.




Struts Survival Guide. Basics to Best Practices
Struts Survival Guide: Basics to Best Practices (J2ee Survival Series)
ISBN: 0974848808
EAN: 2147483647
Year: 2004
Pages: 96

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net