You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Wendy Smoak <We...@asu.edu> on 2002/11/06 22:21:32 UTC

Help with ValidatorForm

If I have a regular ActionForm, all is well.  If I change to:
public final class ContactForm extends ValidatorForm

It's validating on the *first* display of the form and then complaining that
the required field isn't present.  (Of course not... the user hasn't had a
chance to type anything yet!)

The very first time I hit the Struts action with:
http://zzz.yyy.www.edu/dev/editContact.do?contactKey=4100&action=Edit

I get:
Validation Error
  You must correct the following error(s) before proceeding:
  Contact Date is required.

>From the console messages, I can tell that it's not even getting to the code
in the [LookupDispatch]Action.  I see the two filters, the GET and then the
reset method being called:
  BenefactorAccessFilter.doFilter
  Nov 6, 2002 12:58:42 PM org.apache.struts.action.RequestProcessor process
  INFO: Processing a 'GET' for path '/editContact'
  ContactForm.reset

At that point, I see my form with the validation message (above) and nothing
in any of the fields.  (It should have read from the DB and presented the
record to edit.  That works fine as a regular ActionForm.)

The validation.xml is:
<form-validation>
   <formset>
      <form    name="contactForm">
         <field    property="date"
         	   depends="required">
         	     <arg0 key="label.date"/>
                     <var>
                       <var-name>datePatternStrict</var-name>
                       <var-value>MM/dd/yyyy</var-value>
                     </var>
         </field>
      </form>
   </formset>
</form-validation>

I do NOT have validate="true" in the <action> tag:

 <action    path="/editContact"
               type="edu.asu.vpia.example.EditContactAction"
               name="contactForm"
              scope="session"
              input="/WEB-INF/jsp/contact.jsp"
          parameter="action">
      <forward name="resolution"      path="/resolveName.do" />
      <forward name="saved"           path="/WEB-INF/jsp/contactConfirm.jsp"
/>
      <forward name="success"         path="/WEB-INF/jsp/contact.jsp" />
      <forward name="failure"         path="/WEB-INF/jsp/contactFailure.jsp"
/>
    </action>

In fact, I need it to not validate automatically... I need to call the
validate method manually at the last minute, as this is a form where the
user can come and go repeatedly before clicking "Finish" to say that they're
really done with it.

This is my first try with Validation, so if you see anything wrong, no
matter how trivial, please say something!  I'm working from the incomplete
chapter from the O'Reilly book and from the validation example in the 10/5
Struts nightly build.

-- 
Wendy Smoak
Applications Systems Analyst, Sr.
Arizona State University PA Information Resources Management

Re: Help with ValidatorForm

Posted by Eddie Bush <ek...@swbell.net>.
Gotcha!  Validate defaults to true :-O

... so set it to false in your populate action ;-)

-- 
Eddie Bush





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>