2
<document url="./apps.xml">
4
<author>Dan Walker</author>
5
<author>Ted Husted</author>
6
<title>Building Applications</title>
9
<section name="How to Build Applications" href="building_apps"/>
10
<section href="intro" name="About This Document">
12
This document outlines one possible sequence of development steps that can be followed to create a
13
Struts application. It is not intended as a complete description of each
14
referenced development activity. More detailed documentation is available
15
elsewhere and is referenced by "(more...)" links where possible.
19
<section href="caveats" name="Caveats">
21
<li>Requirements development and design are outside of the scope of this document.</li>
22
<li>For help installing Struts, see the <a href="../userGuide/installation.html">Getting Started</a> chapter.</li>
23
<li>There are many other ways to approach Struts development and there are many
24
other features available besides the ones discussed below. This document
25
outlines only one way to get started.</li>
26
<li>This document focuses on form/data centric applications, but may also work with
27
other types of applications.</li>
28
<li>This material was written for Struts 1.1 (beta 2).</li>
32
<section href="overview" name="Overview">
34
<li>Implement data entry forms as JSP files.</li>
35
<li>Implement one or more <code>ActionForm</code> descendents to buffer data
36
between JSPs and Actions.</li>
37
<li>Create an XML document that defines the validation rules for your
39
<li>Implement one or more <code>Action</code> descendents to respond form
41
<li>Create <code>struts-config.xml</code> to associate forms with
43
<li>Create or update <code>web.xml</code> to reference
44
<code>ActionServlet</code>, taglibs used by Struts.</li>
55
<section href="details" name="Details">
57
<li>Implement data entry forms as JSP files.
59
<li>Use elements from the <code>html</code> taglib
60
to define the form elements. <a href="../userGuide/struts-html.html">
62
<li>Use <code>message</code> and other elements from the <code>bean</code>
63
taglib to define the labels and other static text of the form.
64
<a href="../userGuide/struts-bean.html">(more...)</a>
66
<li>Create and maintain a properties file of the text elements
67
to be displayed. <a href="../userGuide/preface.html#resources">(more...)
71
<li>Use <code>property</code> attributes to link form fields to
72
<code>ActionForm</code> instance variables.</li>
75
<li>Implement one or more <code>ActionForm</code> descendents
76
to buffer data between JSPs and Actions.
78
<li>Create get/set pairs that correspond to the property names
79
in your related JSP form. Example:
80
<pre><html:text property="city" /></pre>
82
<pre>getCity() and setCity(String c)</pre>
84
<li>When needed, create a <code>reset</code> method
85
that sets the fields of the <code>ActionForm</code> to their default values. Most ActionForms do not need to do this.</li>
88
<li>Create an XML document that defines the validation rules for your
90
<li>Implement one or more <code>Action</code> descendents
91
to respond to form submissions.
93
<li>Descend from DispatchAction or LookupDispatchAction if you
94
want one class to handle more than one kind of event (example: one Action
95
to handle 'insert', 'update' and 'delete' events, using a different "surrogate" execute method for each). <a href="http://husted.com/struts/tips/002.html">(more...)</a></li>
96
<li>Use the <code>execute</code> method
97
(or its surrogates) of your Action class to interface with objects in your
98
application responsible for database interaction, such as EJBs, etc.
99
<!-- [:TODO: find good doc to link to] -->
101
<li>Use the return value of the <code>execute</code> method
102
(or its surrogates) direct the user interface to the appropriate next page.
103
<!-- [:TODO: find good doc to link to] -->
107
<li>Create <code>struts-config.xml</code> to
108
associate forms with actions. The file minimally needs:</li>
109
<li>Create or update <code>web.xml</code> to
110
reference <code>ActionServlet</code>, taglibs used by Struts. <a href="../userGuide/configuration.html#dd_config"> (more...)</a></li>
115
<li>Use Ant. It can compile, create WAR file, perform XSLT
116
transformations, run unit tests, interact with version control systems,
117
clean up, etc. <a href="http://jakarta.apache.org/ant"> (more...)</a></li>
118
<li>Create and use build script incrementally, as you create
119
files that need to be copied, compiled, etc. </li>
124
<li>Unit test normal java beans with JUnit. <a href="http://www.junit.org"> (more...)</a></li>
125
<li>Unit test JSP, taglibs and conventional servlet components
126
with Cactus. <a href="http://jakarta.apache.org/cactus"> (more...)</a></li>
127
<li>Unit test Action servlets with StrutsTestCase. <a href="http://strutstestcase.sourceforge.net"> (more...)</a></li>
128
<li>Add all unit tests to the build script as a separate
129
target. This target should use the <code>junit</code> tag to launch each TestCase descendent. <a href="http://jakarta.apache.org/ant/manual/OptionalTasks/junit.html"> (more...)</a></li>
134
<li>Build script should create a war file containing the
135
files developed above, along with files that make up the Struts framework.
136
<!-- [:TODO: describe this further, look for doc to link to] -->