Do you extend ActionSupport or just implement Action when trying to do
validation?

Have a look at the User registration example (in CVS only)
<snip>
public class UserRegistration 
                extends ActionSupport 
                implements  ServletRequestAware, 
                                SessionAware, 
                                CommandDriven {

   HttpServletRequest req;
   Map session;

   .... fields, setters and getters .....

   protected String doExecute() throws Exception {
        
        ........code.....

      if (ui != null && username.equals(ui.username)) {
         addError("username", "Sorry. This username is already taken.
Please try another");
         db.close();
         return ERROR;
      } else {
         db.set(new UserInfo(this));
      }

      db.close();
      return SUCCESS;
   }

   protected void doValidation() {

      if (!getHasErrors()) {

         // check if passwords match
         if (!password.equals(confirmedPassword)) {
            addError("password", "Passwords does not match");
            addError("confirmedPassword", "");
         }

         // check if the email is valid by checking the host name
         if (!Validator.checkEmail(this.email, this.netcheck)) {
            addError("email", "This email does not have a valid
hostname");
         }

                .....more code...
         }
      }
   }
}
</snip>

I guess you can chain your actions by setting another action as the
'success' result.

/kjetilhp

> -----Original Message-----
> From: Toby Hede [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 31, 2002 6:11 AM
> To: [EMAIL PROTECTED]
> Subject: [Webwork-user] command driven actions
> 
> 
> I have a couple of queries about command driven actions.
> 
> My commands are working fine, I implement CommandDriven, but 
> I am finding a 
> couple of things:
> - parameters are not being set
> - validation is not occurring
> 
> I have overcome these issues by implmenting Parameter aware 
> to retirve 
> parameters manually and calling doValidate from my doXxx command 
> implementation.
> 
> Is this normal? Does making an action CommandDriven over ride these 
> features? Is there something I am missing?
> 
> My other issue is that I would like to chain actions together 
> somehow, and I 
> was wondering how this is achieved?
> 
> In thos case I am paging through records  - my first action 
> retrieves the 
> records for each page, but when all pages have been viewed I 
> want to trigger 
> another action somehow...
> 
>   JSP -> paging.action1 -> JSP (repeat for N)
> 
>   on N:
> 
>   paging.action2 -> JSP2
> 
> I might be approaching the whole problem the wrong way, so 
> any ideas are 
> welcome.
> 
> 
> 
> _________________________________________________________________
> Chat with friends online, try MSN Messenger: http://messenger.msn.com
> 
> 
> _______________________________________________
> Webwork-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/webwork-user
> 

_______________________________________________
Webwork-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webwork-user

Reply via email to