- Hello World! Application Requirements
- Applying the Model-View-Controller Pattern
- The View Component: The HTML Form and the Form Bean
- MessageResources and Application.properties Files
- The Struts Form Bean: HelloForm.java
- Data Validation and ActionErrors
- The Controller Component: HelloAction.java
- The Model Component (HelloModel.java)
- Passing Data to the View Using Attributes: Constants.java
- Tying It All Together: The struts-config.xml File
This chapter presented a complete, but basic, first Struts application. Its goal was to enable a programmer with a basic understanding of Java and JSP development to quickly come up to speed on how to build applications using Struts.
Specific information presented in the chapter included:
The application requirementsthese were basic and were designed to provide a little bit of functionality in each of the Model, View, and Controller components.
How to analyze application requirements and break them down into components using the Model-View-Controller framework provided by Struts. A primary strength of Struts is the mental framework it provides, which enables developers to quickly break an application into components for development.
View components and how they are built using JSP and Struts custom tags. Also, how the View components are tied to Struts form beans for processing and validating user input.
How View components handle i18n and how presentation text is maintained by storing locale-specific text strings in property files, which are loaded into Struts MessageProperties objects.
How user data entry can be maintained at two levels: Data entry validation is performed in the form bean and business logic validation is performed in the Action class.
How ActionError objects store individual error messages and how ActionErrors objects store ActionError objects. Also, ActionError information is available to the Struts View components either directly or via the Struts <html:errors> custom tag.
How Action classes work, including a detailed walk-through of a basic Action class.
How Model components provide a powerful ability to hide implementation details and simplify interacting with remote systems. Also, how Controller components interact with Model components.
How information is passed between the Controller and View components by using the setAttribute() and getAttribute() methods of the request or session objects. How the string constants used in this process are defined in a file called Constants.java by convention.
How Struts applications are configured using the struts-config.xml file.