Apache Struts Web Application Framework
FAQs
Kickstart
Newbie
How to Help
Howto Guides
Action Forms
Building Apps
Database
Indexed Properties
SSL
IDE Guides
Eclipse
Netbeans
Quick Links
Welcome
News and Status
Resources
User and Developer Guides
FAQs and HowTos *
How to Build Applications

Contributors:

  • Dan Walker
  • Ted Husted
About This Document

This document outlines one possible sequence of development steps that can be followed to create a Struts application. It is not intended as a complete description of each referenced development activity. More detailed documentation is available elsewhere and is referenced by "(more...)" links where possible.

Caveats
  1. Requirements development and design are outside of the scope of this document.
  2. For help installing Struts, see the Getting Started chapter.
  3. There are many other ways to approach Struts development and there are many other features available besides the ones discussed below. This document outlines only one way to get started.
  4. This document focuses on form/data centric applications, but may also work with other types of applications.
  5. This material was written for Struts 1.1 (beta 2).
Overview
  1. Implement data entry forms as JSP files.
  2. Implement one or more ActionForm descendents to buffer data between JSPs and Actions.
  3. Create an XML document that defines the validation rules for your application.
  4. Implement one or more Action descendents to respond form submissions.
  5. Create struts-config.xml to associate forms with actions.
  6. Create or update web.xml to reference ActionServlet, taglibs used by Struts.
  7. Parallel Tasks
    1. Building
    2. Unit Testing
    3. Deployment
Details
  1. Implement data entry forms as JSP files.
    1. Use elements from the html taglib to define the form elements. (more...)
    2. Use message and other elements from the bean taglib to define the labels and other static text of the form. (more...)
      1. Create and maintain a properties file of the text elements to be displayed. (more...)
    3. Use property attributes to link form fields to ActionForm instance variables.
  2. Implement one or more ActionForm descendents to buffer data between JSPs and Actions.
    1. Create get/set pairs that correspond to the property names in your related JSP form. Example:
      <html:text property="city" />
      needs:
      getCity() and setCity(String c)
    2. When needed, create a reset method that sets the fields of the ActionForm to their default values. Most ActionForms do not need to do this.
  3. Create an XML document that defines the validation rules for your application.
  4. Implement one or more Action descendents to respond to form submissions.
    1. Descend from DispatchAction or LookupDispatchAction if you want one class to handle more than one kind of event (example: one Action to handle 'insert', 'update' and 'delete' events, using a different "surrogate" execute method for each). (more...)
    2. Use the execute method (or its surrogates) of your Action class to interface with objects in your application responsible for database interaction, such as EJBs, etc.
    3. Use the return value of the execute method (or its surrogates) direct the user interface to the appropriate next page.
  5. Create struts-config.xml to associate forms with actions. The file minimally needs:
    1. <form-beans> section to relate form-beans with ActionForms (more...)
    2. <action-mappings> section to relate <html:form> actions with Action classes (more...)
    3. <message-resources> to make your ApplicationResources available to the rest of the app
    4. <plug-in> section to link in the Struts validator and other extensions (more...)
  6. Create or update web.xml to reference ActionServlet, taglibs used by Struts. (more...)
  7. Parallel Tasks
    1. Building
      1. Use Ant. It can compile, create WAR file, perform XSLT transformations, run unit tests, interact with version control systems, clean up, etc. (more...)
      2. Create and use build script incrementally, as you create files that need to be copied, compiled, etc.
    2. Unit Testing
      1. Unit test normal java beans with JUnit. (more...)
      2. Unit test JSP, taglibs and conventional servlet components with Cactus. (more...)
      3. Unit test Action servlets with StrutsTestCase. (more...)
      4. Add all unit tests to the build script as a separate target. This target should use the junit tag to launch each TestCase descendent. (more...)
    3. Deployment
      1. Build script should create a war file containing the files developed above, along with files that make up the Struts framework.

Copyright (c) 2000-2003, Apache Software Foundation