Did you add a "page" property to your DynaValidatorAction form definition in the struts-config.xml?
Niall ----- Original Message ----- From: "Dean A. Hoover" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, March 12, 2004 3:15 PM Subject: wizard best practices? > I've been reading books, the internet, this list, and > experimenting, attempting to build a model for > best practice for a wizard utilizing struts 1.1 and > DynaValidatorAction. I've got a simple model > working but validation does not work. In other > words, the validator framework does not seem to > be doing its thing. I've recently used DynaValidatorAction > on single forms with great success. The other thing > I am wondering about, assuming the Validator > will validate, is once the code runs the > Action, I'd like to be able to do secondary > validation based on business logic. This means > I would need to get the page number, and I am > not sure I understand how this works. I have a hidden > field on each form in the wizard for page. This > presumably works in conjuction with the field > page attribute in the validation config file. If someone > can explain how I can complete this thing, I would > be grateful. Also, maybe this example could be added > to the struts website as I have to believe I am not the > only one struggling with this. > > Many thanks. > Dean Hoover > > Here are the files: > > === struts-config.xml === > <?xml version="1.0" encoding="ISO-8859-1" ?> > <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD > Struts Configuration 1.0//EN" > "http:/jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"> > > <struts-config> > <form-beans> > <form-bean name="MyWizard" > type="org.apache.struts.validator.DynaValidatorForm"> > <form-property name="x" type="java.lang.String"/> > <form-property name="y" type="java.lang.String"/> > <form-property name="z" type="java.lang.String"/> > > <form-property name="method" type="java.lang.String"/> > </form-bean> > > </form-beans> > > <action-mappings> > > <action path="/mywizard1" > type="MyWizardAction" > name="MyWizard" > scope="session" > input="/mywizard1.jsp" > parameter="method" > validate="true"> > > <forward name="next" path="/mywizard2.jsp"/> > <forward name="cancel" path="/mywizardcancel.html"/> > </action> > > <action path="/mywizard2" > type="MyWizardAction" > name="MyWizard" > scope="session" > input="/mywizard2.jsp" > parameter="method" > validate="true"> > > <forward name="previous" path="/mywizard1.jsp"/> > <forward name="next" path="/mywizard3.jsp"/> > <forward name="cancel" path="/mywizardcancel.jsp"/> > </action> > > <action path="/mywizard3" > type="MyWizardAction" > name="MyWizard" > scope="session" > input="/mywizard3.jsp" > parameter="method" > validate="true"> > > <forward name="previous" path="/mywizard2.jsp"/> > <forward name="finish" path="/mywizarddone.jsp"/> > <forward name="cancel" path="/mywizardcancel.jsp"/> > </action> > > </action-mappings> > > <message-resources parameter="resources.application"/> > > <plug-in className="org.apache.struts.validator.ValidatorPlugIn"> > <set-property property="pathnames" > value="/WEB-INF/validator-rules.xml, > /WEB-INF/validation.xml"/> > </plug-in> > > </struts-config> > === validation.xml === > <form-validation> > <formset> > <form name="MyWizard"> > <!-- page 1 --> > <field property="x" page="1" depends="required"/> > > <!-- page 2 --> > <field property="y" page="2" depends="required"/> > > <!-- page 3 --> > <field property="z" page="3" depends="required"/> > </form> > </formset> > </form-validation> > === mywizard1.jsp === > <%@ taglib uri="/tags/struts-bean" prefix="bean" %> > <%@ taglib uri="/tags/struts-html" prefix="html" %> > <html:html> > <body> > <h3>Page 1</h3> > <html:errors/> > <html:form method="post" action="/mywizard1.do"> > <html:hidden property="page" value="1"/> > x = <html:text property="x"/> > <html:submit property="method"><bean:message > key="button.next"/></html:submit> > <html:submit property="method"><bean:message > key="button.cancel"/></html:submit> > </html:form> > </body> > </html:html> > === mywizard2.jsp === > <%@ taglib uri="/tags/struts-bean" prefix="bean" %> > <%@ taglib uri="/tags/struts-html" prefix="html" %> > <html:html> > <body> > <h3>Page 2</h3> > <html:errors/> > <html:form method="post" action="/mywizard2.do"> > <html:hidden property="page" value="2"/> > y = <html:text property="y"/> > <html:submit property="method"><bean:message > key="button.previous"/></html:submit> > <html:submit property="method"><bean:message > key="button.next"/></html:submit> > <html:submit property="method"><bean:message > key="button.cancel"/></html:submit> > </html:form> > </body> > </html:html> > === mywizard3.jsp === > <%@ taglib uri="/tags/struts-bean" prefix="bean" %> > <%@ taglib uri="/tags/struts-html" prefix="html" %> > <html:html> > <body> > <h3>Page 3</h3> > <html:errors/> > <html:form method="post" action="/mywizard3.do"> > <html:hidden property="page" value="3"/> > z = <html:text property="z"/> > <html:submit property="method"><bean:message > key="button.previous"/></html:submit> > <html:submit property="method"><bean:message > key="button.finish"/></html:submit> > <html:submit property="method"><bean:message > key="button.cancel"/></html:submit> > </html:form> > </body> > </html:html> > === mywizarddone.jsp === > <%@ taglib uri="/tags/struts-bean" prefix="bean" %> > <%@ taglib uri="/tags/struts-html" prefix="html" %> > <html:html> > <body> > x = <bean:write name="MyWizard" property="x"/><br/> > y = <bean:write name="MyWizard" property="y"/><br/> > z = <bean:write name="MyWizard" property="z"/><br/> > </body> > </html:html> > === mywizardcanel.jsp === > <html><body>CANCEL</body></html> > === MyWizardAction.java === > import java.util.*; > > public class MyWizardAction extends LookupDispatchAction > { > protected Map getKeyMethodMap() > { > Map map = new HashMap(); > map.put("button.next", "next"); > map.put("button.previous", "previous"); > map.put("button.finish", "finish"); > map.put("button.cancel", "cancel"); > return map; > } > > public ActionForward next > ( > ActionMapping mapping, > ActionForm form, > HttpServletRequest request, > HttpServletResponse response > ) > { > // passed the validator stuff, what if we wanted to do some > // business layer validation at this stage, based on 'page'? > > return mapping.findForward("next"); > } > > public ActionForward previous > ( > ActionMapping mapping, > ActionForm form, > HttpServletRequest request, > HttpServletResponse response > ) > { > return mapping.findForward("previous"); > } > > public ActionForward finish > ( > ActionMapping mapping, > ActionForm form, > HttpServletRequest request, > HttpServletResponse response > ) > { > return mapping.findForward("finish"); > } > > public ActionForward cancel > ( > ActionMapping mapping, > ActionForm form, > HttpServletRequest request, > HttpServletResponse response > ) > { > return mapping.findForward("cancel"); > } > } > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]