husted 2002/12/22 11:41:19
Modified: doc/userGuide building_view.xml
Log:
Conform use of pre/code tags; no content changes.
Revision Changes Path
1.20 +124 -125 jakarta-struts/doc/userGuide/building_view.xml
Index: building_view.xml
===================================================================
RCS file: /home/cvs/jakarta-struts/doc/userGuide/building_view.xml,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- building_view.xml 17 Dec 2002 07:21:05 -0000 1.19
+++ building_view.xml 22 Dec 2002 19:41:19 -0000 1.20
@@ -130,18 +130,17 @@
for the application. In the case described above, it would be
<code>com.mycompany.mypackage.MyApplication</code>.
</p>
-<pre>
-<servlet>
- <servlet-name>action</servlet-name>
- <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
- <init-param>
- <param-name>application</param-name>
- <param-value>com.mycompany.mypackage.MyResources</param-value>
- </init-param>
- <.../>
-</servlet>
-</pre>
-
+<pre><code><![CDATA[
+<servlet>
+ <servlet-name>action</servlet-name>
+ <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
+ <init-param>
+ <param-name>application</param-name>
+ <param-value>com.mycompany.mypackage.MyResources</param-value>
+ </init-param>
+ <!-- ... -->
+</servlet>
+]]></code></pre>
<p>
The important thing is for the resource bundle to be found on the
class path for your application. Another approach is to store
@@ -155,12 +154,12 @@
that copies the contents of a <code>src/conf</code>
directory to the <code>classes</code> directory:
</p>
- <pre>
- <!-- Copy any configuration files -->
- <copy todir="classes">
- <fileset dir="src/conf"/>
- </copy>
- </pre>
+<pre><code><![CDATA[
+<!-- Copy any configuration files -->
+<copy todir="classes">
+ <fileset dir="src/conf"/>
+</copy>
+]]></code></pre>
</section>
<section name="3.3 Forms and FormBean Interactions" href="form_beans">
@@ -190,12 +189,10 @@
standard HTML and JSP pages. For example, an input element for a
<code>username</code> field might look like this (in JSP):
</p>
-
-<pre>
-<input type="text" name="username"
- value="<%= loginBean.getUsername() %>"/>
-</pre>
-
+<pre><code><![CDATA[
+<input type="text" name="username"
+ value="<%= loginBean.getUsername() >"/>
+]]></code></pre>
<p>
which is difficult to type correctly, confuses HTML developers who are
not knowledgeable about programming concepts, and can cause problems with
@@ -203,11 +200,9 @@
building forms, based on the Custom Tag Library facility of JSP 1.1.
The case above would be rendered like this using Struts:
</p>
-
-<pre>
-<html:text property="username"/>
-</pre>
-
+<pre><code><![CDATA[
+<html:text property="username"/>;
+]]></code></pre>
<p>
with no need to explicitly refer to the JavaBean from which the initial
value is retrieved. That is handled automatically by the JSP tag, using
@@ -232,57 +227,61 @@
example application included with Struts) named <code>logon.jsp</code>:
</p>
<hr/>
-<pre>
-<%@ page language="java" %>
-<%@ taglib uri="/WEB-INF/struts-html.tld"
- prefix="html" %>
-<%@ taglib uri="/WEB-INF/struts-bean.tld"
- prefix="bean" %>
-<html:html>
-<head>
-<title>
- <bean:message key="logon.title"/>
-</title>
-</head>
-<body bgcolor="white">
-<html:errors/>
-<html:form action="/logon" focus="username">
-<table border="0" width="100%">
- <tr>
- <th align="right">
- <bean:message key="prompt.username"/>
- </th>
- <td align="left">
- <html:text property="username"
- size="16"/>
- </td>
- </tr>
- <tr>
- <th align="right">
- <bean:message key="prompt.password"/>
- </th>
- <td align="left">
- <html:password property="password"
- size="16"/>
- </td>
- </tr>
- <tr>
- <td align="right">
- <html:submit>
- <bean:message key="button.submit"/>
- </html:submit>
- </td>
- <td align="right">
- <html:reset>
- <bean:message key="button.reset"/>
- </html:reset>
- </td>
- </tr>
-</table>
-</html:form>
-</body>
-</html:html>
-</pre>
+<pre><code><![CDATA[
+<%@ page language="java" %>
+<%@ taglib
+ uri="/WEB-INF/struts-html.tld"
+ prefix="html" %>
+<%@
+ taglib uri="/WEB-INF/struts-bean.tld"
+ prefix="bean" %>
+<html:html>
+<head>
+<title>
+ <bean:message key="logon.title"/>
+</title>
+</head>
+<body bgcolor="white">
+<html:errors/>
+<html:form action="/logon" focus="username">
+<table border="0" width="100%">
+<tr>
+<th align="right">
+ <bean:message key="prompt.username"/>
+</th>
+<td align="left">
+ <html:text
+ property="username"
+ size="16"/>
+</td>
+</tr>
+<tr>
+<th align="right">
+ <bean:message key="prompt.password"/>
+</th>
+<td align="left">
+ <html:password
+ property="password"
+ size="16"/>
+</td>
+</tr>
+<tr>
+<td align="right">
+ <html:submit>
+ <bean:message key="button.submit"/>
+ </html:submit>
+</td>
+<td align="right">
+ <html:reset>
+ <bean:message key="button.reset"/>
+ </html:reset>
+</td>
+</tr>
+</table>
+</html:form>
+</body>
+</html:html>
+]]></code></pre>
<hr/>
<p>
The following items illustrate the key features of form handling in
Struts,
@@ -363,25 +362,25 @@
</p>
<hr/>
-<pre>
-<%@page language="java">
-<%@taglib uri="/WEB-INF/struts-html.tld"
+<pre><code><![CDATA[
+<%@page language="java">
+<%@taglib uri="/WEB-INF/struts-html.tld"
prefix="html">
-<html:form action="uploadAction.do" enctype="multipart/form-data">
+<html:form action="uploadAction.do" enctype="multipart/form-data">
Please Input Text:
- <html:text property="myText"><br/>
- Please Input The File You Wish to Upload:<br/>
- <html:file property="myFile"><br />
- <html:submit />
-</html:form>
-</pre>
+ <html:text property="myText">
+ Please Input The File You Wish to Upload:
+ <html:file property="myFile">
+ <html:submit />
+</html:form>
+]]></code></pre>
<hr/>
<p>
The next step is to create your ActionForm bean:
</p>
<hr/>
-<pre>
+<pre><code><![CDATA[
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
@@ -403,7 +402,7 @@
return myFile;
}
}
-</pre>
+]]></code></pre>
<hr/>
<p>
Look at the Javadocs for <code><a
href="../api/org/apache/struts/upload/FormFile.html">FormFile</a></code>
@@ -493,10 +492,10 @@
class:
</p>
-<pre>public ActionErrors
+<pre><code><![CDATA[
validate(ActionMapping mapping,
HttpServletRequest request);
-</pre>
+]]></code></pre>
<p>
The <code>validate</code> method is called by the controller servlet
after the bean
@@ -539,29 +538,30 @@
<p>
Configuring the Validator to perform form validation is easy.<br/>
<ol>
- <li>The ActionForm bean must extend ValidatorForm</li>
- <li>The form's JSP must include the <a
href="struts-html.html"><html:javascript></a> tag for client side
validation.</li>
- <li>You must define the validation rules in an xml file like this:<br/>
- <pre>
- <form-validation>
- <formset>
- <form name="logonForm">
- <field property="username" depends="required">
- <msg name="required" key="error.username"/>
- </field>
- </form>
- </formset>
- </form-validation>
- </pre>
- <br/>
+ <li>The ActionForm bean must extend ValidatorForm</li>
+ <li>The form's JSP must include the <a
href="struts-html.html"><html:javascript></a> tag for client side
validation.</li>
+ <li>You must define the validation rules in an xml file like this:
+<pre><code><![CDATA[
+<form-validation>
+ <formset>
+ <form name="logonForm">
+ <field property="username" depends="required">
+ <msg name="required" key="error.username"/>
+ </field>
+ </form>
+ </formset>
+</form-validation>
+]]></code></pre>
The msg element points to the message resource key to use when generating the
error message.
</li>
- <li>Lastly, you must enable the ValidatorPlugin in the struts-config.xml file
like this:<br/>
- <pre>
- <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
- <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,
/WEB-INF/validation.xml"/>
- </plug-in>
- </pre>
+ <li>Lastly, you must enable the ValidatorPlugin in the struts-config.xml file
like this:
+<pre><code><![CDATA[
+<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
+ <set-property
+ property="pathnames"
+ value="/WEB-INF/validator-rules.xml, /WEB-INF/validation.xml"/>
+</plug-in>
+]]></code></pre>
</li>
</ol>
</p>
@@ -720,12 +720,13 @@
such as XML. If a complete page is being rendered, and can be output
using a PrintWriter, this is very easy to do from an Action:
</p>
- <pre>
- response.setContentType("text/plain"); // or text/xml
- PrintWriter writer = response.getWriter();
- // use writer to render text
- return(null);
- </pre>
+
+<pre><code><![CDATA[
+response.setContentType("text/plain"); // or text/xml
+PrintWriter writer = response.getWriter();
+// use writer to render text
+return(null);
+]]></code></pre>
</section>
@@ -742,15 +743,13 @@
attribute values. For instance, to print a message from a properties
file based on a resource key, you would use the
<code>bean:write</code> tag, perhaps like this:
- <pre>
- <bean:message key='<%= stringvar %>'/></pre>
+<pre><code><![CDATA[<bean:message key='<%= stringvar %>'/>]]></code></pre>
</p>
<p>
This assumes that <code>stringvar</code> exists as a JSP scripting
variable. If you're using the <strong>Struts-EL</strong> library, the
reference looks very similar, but slightly different, like this:
- <pre>
- <bean-el:message key="${stringvar}"/></pre></pre>
+<pre><code><![CDATA[<bean-el:message key="${stringvar}"/>]]></code></pre>
</p>
<p>
If you want to know how to properly use the <strong>Struts-EL</strong>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>