I have a validate() method in my ActionForm class that includes some cleanup
(removes redundant whitespace) of some of the ActionForm bean's properties.
The related Action has validate="true" set in struts-config. So validate()
should always be called.

The Action class then uses the ActionsForm's getters to read these
properties and saves them.

However, the saved properties have only been cleaned when errors are found
by the validate() method.

Why?

The validate() method is ALWAYS called and executes the cleanup methods on
the properties whether validate() discover errors or not, right?

Specifically, in the code below, the answer1, answer2, etc., are only
"cleaned" if there is an error found in the email address.

/*** code snippet ***/

 public ActionErrors validate(
  ActionMapping mapping,
  HttpServletRequest request) {

  /* clean redundant whitespace from answers properties */
  answer1 = cleanWhitespace(answer1);
  answer2 = cleanWhitespace(answer2);
  answer3 = cleanWhitespace(answer3);

  ActionErrors errors = new ActionErrors();

  /*** validate email address ***/

  /* check is email address is not empty */
  if ((emailAddr == null) || (emailAddr.length() < 1)){
   errors.add("emailaddressempty",
    new ActionError("errors.required.emailaddress"));
  }

...

    return errors;
}




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

Reply via email to