With a little further investigation I see that the page value does not
get set in the validationForm using html:hidden approach as outlined
below. Ie, this doen't work:

<html:hidden name="validateForm" property="page" value="1" />

When I print out the value of the page field in the action, it is still set
to zero.

How do you set the page property?

Also, this seems to imply the validator is VERY shaky over multiple
pages. For example, the properties on my second page are marked
as required, and they don't get validated in the first action (this seems
to show that the page based validation is working), yet on the second
page, the associated action tries to validate the page 1 properties!!!

I believe the server side validation validates any page <= the current page and the client side javascript just validates the current page.


David


Arrrg!! What's going on! Has anyone got this to work?


Brian


----- Original Message ----- From: "Brian McSweeney" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Thursday, May 29, 2003 2:42 PM Subject: Form validation over multiple pages


Hi all,


I'm almost there with using the validator over several pages with a single
form.
However I'm getting a strange little error. The first page is validating
fine, and it
doesn't seem to try to validate the info required on the second page -
correct.
However once I try to validate the second page, the javascript validates
correctly,
but the server side validation returns an error saying the first page's
required field
needs validating.

I think it might be because I'm not sure how to pass the page parameter to
the action.
I've tried using a html:hidden tag. Anyway, snippets from the jsps, struts
config and
validation.xml file are included below.

If someone could help me out I'd be very grateful. Thanks very much,
Brian.




My first jsp named "validatestep1.jsp" looks like:


<html:javascript formName="validateForm" page="1"/>

<html:form action="/secure/validateStep1.jspa" onsubmit="return
validateValidateForm(this);" method="post">
    <html:hidden name="validateForm" property="page" value="1" />
<table>
 <tr><td>username</td>
  <td><html:text name="validateForm" property="userName" /></td>
 </tr>
 <tr>
  <td colspan="2" align="center">
   <html:image border="0" page="/images/button_submit.gif"/>
  </td>
  </tr>
</table>
</html:form>

My second jsp named "validatestep2.jsp" looks like

<html:javascript formName="validateForm" page="2"/>
<html:form action="/secure/validateStep2.jspa" onsubmit="return
validateValidateForm(this);" method="post">
    <html:hidden name="validateForm" property="page" value="2" />
<table>
 <tr>
  <td>credit card with no spaces or dashes</td>
  <td><html:text name="validateForm" property="creditCard" /></td>
 </tr>
 <tr>
  <td colspan="2" align="center">
   <html:image border="0" page="/images/button_submit.gif"/>
  </td>
  </tr>
</table>
</html:form>


in my struts config I have


    <action
      path="/secure/validateStep1"
      type="ValidateStep1Action"
      name="validateForm"
      scope="session"
      input="/validatestep1.jsp"
      unknown="false"
      validate="true"
    >
      <forward
        name="success"
        path="/validatestep2.jsp"
        redirect="false"
      />

and then

    <action
      path="/secure/validateStep2"
      type="ValidateStep2Action"
      name="validateForm"
      scope="session"
      input="/validatestep2.jsp"
      unknown="false"
      validate="true"
    >
      <forward
        name="success"
        path="/validated.jsp"
        redirect="false"
      />

In my validation.xml file I have


<form name="validateForm"> <field property="userName" depends="required,minlength" page="1">

              <field property="creditCard" depends="required,creditCard"
page="2">



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to