You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by hu...@apache.org on 2006/02/10 20:43:45 UTC
svn commit: r376814 - in /struts/extras/trunk/xdocs: dispatchValidator.xml
navigation.xml
Author: husted
Date: Fri Feb 10 11:43:43 2006
New Revision: 376814
URL: http://svn.apache.org/viewcvs?rev=376814&view=rev
Log:
Checkstyle Roundup
* Extra package reformatted with latest Jalopy settings. Stylistic changes only.
Modified:
struts/extras/trunk/xdocs/dispatchValidator.xml
struts/extras/trunk/xdocs/navigation.xml
Modified: struts/extras/trunk/xdocs/dispatchValidator.xml
URL: http://svn.apache.org/viewcvs/struts/extras/trunk/xdocs/dispatchValidator.xml?rev=376814&r1=376813&r2=376814&view=diff
==============================================================================
--- struts/extras/trunk/xdocs/dispatchValidator.xml (original)
+++ struts/extras/trunk/xdocs/dispatchValidator.xml Fri Feb 10 11:43:43 2006
@@ -18,45 +18,59 @@
-->
<document>
- <properties>
- <title>Using the DispatchAction and Validator</title>
- </properties>
+ <properties>
+ <title>Using the DispatchAction and Validator</title>
+ </properties>
+
+ <body>
+
+ <section name="Dispatching And Validating">
+
+ <subsection name="Overview">
+
+ <p>
+ This is simple example to illustrate how to build a
+ multi-page
+ wizard that utilizes both the
+ <code>DispatchAction</code>
+ and Commons Validator.
+ Using the
+ <code>DispatchAction</code>
+ helps to minimize the number of action classes
+ while the Validator supports the declarative
+ (non-programmatic) specification of
+ form field validations.
+ </p>
+
+ </subsection>
+
+ <subsection name="Using the DispatchAction">
+
+ <p>
+ The example used is a simple two page wizard. The first
+ page prompts
+ for a name, while the second for an address.
+ The application URL has the form
+ </p>
-<body>
-
-<section name="Dispatching And Validating">
-
-<subsection name="Overview">
-
- <p>
- This is simple example to illustrate how to build a multi-page
- wizard that utilizes both the <code>DispatchAction</code> and Commons Validator.
- Using the <code>DispatchAction</code> helps to minimize the number of action classes
- while the Validator supports the declarative (non-programmatic) specification of
- form field validations.
- </p>
-
-</subsection>
-
-<subsection name="Using the DispatchAction">
-
- <p>
- The example used is a simple two page wizard. The first page prompts
- for a name, while the second for an address.
- The application URL has the form
- </p>
-
-<source><![CDATA[
+ <source><![CDATA[
http://localhost:8080/howto/name.do?submitName=enterName
]]></source>
- <p>
- where the <code>submitName</code> parameter is used to specify the name
- of the method in the action class that will be called to
- process the request. In the action mapping the value of the
- <code>parameter</code> attribute specifies the name of the dispatch request parameter (i.e. <code>parameter="submitName"</code>).
- </p>
+ <p>
+ where the
+ <code>submitName</code>
+ parameter is used to specify the name
+ of the method in the action class that will be called to
+ process the request. In the action mapping the value of
+ the
+ <code>parameter</code>
+ attribute specifies the name of the dispatch request
+ parameter (i.e.
+ <code>parameter="submitName"</code>
+ ).
+ </p>
-<source><![CDATA[
+ <source><![CDATA[
<action path="/name"
type="com.acme.AcmeAction"
name="acmeForm"
@@ -70,9 +84,11 @@
</action>
]]></source>
-The method <code>enterName</code> simply forwards to the first page.
+ The method
+ <code>enterName</code>
+ simply forwards to the first page.
-<source><![CDATA[
+ <source><![CDATA[
public ActionForward enterName(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
@@ -84,19 +100,29 @@
}
]]></source>
-On the page <code>name.jsp</code> is a hidden field for the <code>submitName</code> parameter.
-
-Submitting the name page calls method <code>enterAddress</code> by using
-Javascript to set the <code>submitName</code> parameter
+ On the page
+ <code>name.jsp</code>
+ is a hidden field for the
+ <code>submitName</code>
+ parameter.
+
+ Submitting the name page calls method
+ <code>enterAddress</code>
+ by using
+ Javascript to set the
+ <code>submitName</code>
+ parameter
-<source><![CDATA[
+ <source><![CDATA[
<html:submit onclick="this.form.submitName.value='enterAddress'"/>
]]></source>
-The <code>enterAddress</code> method then forwards to the address page.
+ The
+ <code>enterAddress</code>
+ method then forwards to the address page.
-<source><![CDATA[
+ <source><![CDATA[
public ActionForward enterAddress(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
@@ -107,22 +133,27 @@
}
]]></source>
-On the <code>adddress.jsp</code> page, we again dynamically set the <code>submitName</code>
-parameter.
+ On the
+ <code>adddress.jsp</code>
+ page, we again dynamically set the
+ <code>submitName</code>
+ parameter.
-<source><![CDATA[
+ <source><![CDATA[
<html:submit value="submit" onclick="this.form.submitName.value='submitAddress'"/>
]]></source>
-And the action path that is submitted is
+ And the action path that is submitted is
-<source><![CDATA[
+ <source><![CDATA[
<html:form action="/address">
]]></source>
-The action mapping for <code>/address</code> is
+ The action mapping for
+ <code>/address</code>
+ is
-<source><![CDATA[
+ <source><![CDATA[
<action path="/address"
type="com.acme.AcmeAction"
name="acmeForm"
@@ -139,20 +170,26 @@
</action>
]]></source>
-Note that two action mappings are required to handle the page flow (we'll discuss why
-in the next section).
+ Note that two action mappings are required to handle the page
+ flow (we'll discuss why
+ in the next section).
+
+ </subsection>
+
+ <subsection name="Validations">
+
+ Let's now add some validations to require input fields using
+ the
+ Validator. In validation.xml, there's a
+ <code>formset</code>
+ definition
+ that specifies two field validations for the form bean
+ named
+ <code>acmeForm</code>
+ .
-</subsection>
-<subsection name="Validations">
-
-Let's now add some validations to require input fields using the
-Validator. In validation.xml, there's a <code>formset</code> definition
-that specifies two field validations for the form bean
-named <code>acmeForm</code>.
-
-
-<source><![CDATA[
+ <source><![CDATA[
<formset>
<form name="acmeForm">
<field property="firstName" page="1" depends="required">
@@ -165,59 +202,76 @@
</formset>
]]></source>
-We need to identify the page where the input field resides so that
-we can control which validations are triggered for a given form
-submission. Without using the page property, any request that
-involves the <code>acmeForm</code> would trigger all of the validations
-associated with <code>acmeForm</code> (even validations for fields that the user
-has not seen yet).
+ We need to identify the page where the input field resides so
+ that
+ we can control which validations are triggered for a given
+ form
+ submission. Without using the page property, any request that
+ involves the
+ <code>acmeForm</code>
+ would trigger all of the validations
+ associated with
+ <code>acmeForm</code>
+ (even validations for fields that the user
+ has not seen yet).
-On each of the pages, a hidden field is used to identify
-the page number.
+ On each of the pages, a hidden field is used to identify
+ the page number.
- In <code>name.jsp</code>
+ In
+ <code>name.jsp</code>
-<source><![CDATA[
+ <source><![CDATA[
<html:hidden property="page" value="1"/>
]]></source>
- In <code>address.jsp</code>
+ In
+ <code>address.jsp</code>
-<source><![CDATA[
+ <source><![CDATA[
<html:hidden property="page" value="2"/>
]]></source>
-The Validator will use the value of the page property in determining which validations to run.
-
-Now let's revisit the reason for having two action mappings. An action mapping
-is required for each page since the <code>input</code> attribute specifies the page to forward
-to in case validation fails. Therefore we need to define an action mapping for each page
-that could be displayed after a validation fails.
-
-</subsection>
-
-<subsection name="Cancel and Previous">
-
-The tricky part is how to setup Previous and Cancel buttons
-for each of the pages. If the user clicks Previous then
-the validations for the currrent page should not be triggered.
-For Cancel, none of the validations should be triggered.
+ The Validator will use the value of the page property in
+ determining which validations to run.
-The solution for Previous is to set the page number property
-to the number of the previous page, effectively circumventing
-the validations associated with the current page.
+ Now let's revisit the reason for having two action mappings.
+ An action mapping
+ is required for each page since the
+ <code>input</code>
+ attribute specifies the page to forward
+ to in case validation fails. Therefore we need to define an
+ action mapping for each page
+ that could be displayed after a validation fails.
+
+ </subsection>
+
+ <subsection name="Cancel and Previous">
+
+ The tricky part is how to setup Previous and Cancel buttons
+ for each of the pages. If the user clicks Previous then
+ the validations for the currrent page should not be triggered.
+ For Cancel, none of the validations should be triggered.
+
+ The solution for Previous is to set the page number property
+ to the number of the previous page, effectively circumventing
+ the validations associated with the current page.
-<source><![CDATA[
+ <source><![CDATA[
<html:submit value="previous"
onclick="this.form.submitName.value='previous'; this.form.page.value='1'"/>
]]></source>
-For cancel, there are two options. We could use the Struts Taglib
-Cancel button or create an action specifically designed to process
-a cancel request. The <code>cancel</code> action has no associated validations.
+ For cancel, there are two options. We could use the Struts
+ Taglib
+ Cancel button or create an action specifically designed to
+ process
+ a cancel request. The
+ <code>cancel</code>
+ action has no associated validations.
-<source><![CDATA[
+ <source><![CDATA[
<action path="/cancel"
type="com.acme.CancelAction">
@@ -227,17 +281,21 @@
</action>
]]></source>
-And the Cancel button submits to the <code>/cancel</code> action path.
+ And the Cancel button submits to the
+ <code>/cancel</code>
+ action path.
-<source><![CDATA[
+ <source><![CDATA[
<html:submit value="cancel" onclick="this.form.action='/acme/cancel.do'"/>
]]></source>
-The full example is <a href="dispatchValidator.zip"> here </a>.
+ The full example is
+ <a href="dispatchValidator.zip">here</a>
+ .
-</subsection>
+ </subsection>
- </section>
- </body>
+ </section>
+ </body>
</document>
Modified: struts/extras/trunk/xdocs/navigation.xml
URL: http://svn.apache.org/viewcvs/struts/extras/trunk/xdocs/navigation.xml?rev=376814&r1=376813&r2=376814&view=diff
==============================================================================
--- struts/extras/trunk/xdocs/navigation.xml (original)
+++ struts/extras/trunk/xdocs/navigation.xml Fri Feb 10 11:43:43 2006
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="Struts Extras">
-<title>Apache Struts - Struts Extras</title>
+ <title>Apache Struts - Struts Extras</title>
<body>
<menu name="FAQs and HOWTOs">
- <item name="Dispatching And Validating" href="dispatchValidator.html"/>
+ <item name="Dispatching And Validating"
+ href="dispatchValidator.html"/>
</menu>
<menu name="Quick Links">
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org