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 2003/05/02 22:46:58 UTC

Validating only one field, only sometimes?

I'm using DynaValidatorForm, and while I have validate="true" in
struts-config, I've overridden the 'validate' method:

   public ActionErrors validate( ActionMapping mapping, HttpServletRequest
request )
   {
      ActionErrors errors = null;
      /*
       *  only validate if the user has clicked "Finish"
       */
     if ( "Finish".equals( request.getParameter("userAction") ) ) {
         
         log.debug( "User has Finished, validating..." );
         errors = super.validate( mapping, request );
      }
      return errors;
   }

But now... I find that if userAction is 'Add Email' then I need to validate
just one field (the email address to be added).  Is there a way, from within
the 'validate' method, I can get ahold of the validator and make it do just
that one validation?

Or, since there is a LookupDispatchAction involved, is there a way to have
different sets of validations that are based on the "userAction" parameter,
instead of validating either the entire form or none of it?

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