Don't validation errors go to input? Like so:

     <action name="UserTest_*"  method="{1}"
 class="com.simple.validation.Test">
             <result name="error">/pages/error.jsp</result>
             <result name="input">/pages/welcome-input.jsp</result>
             <result name="success">/pages/welcome.jsp</result>
             <interceptor-ref name="guest"/>
         </action>

I put the annotations on the setters.

@RequiredStringValidator(type = ValidatorType.FIELD, message = "You must
enter a password.")

@StringLengthFieldValidator(type = ValidatorType.SIMPLE, trim = true,
minLength = "6", maxLength = "100", fieldName = "pwd", message = "Password
must be at least 6 characters")

public void setPwd(String password) {
        this.pwd = password;
    }

Regards,
Randy Burgess
Sr. Web Applications Developer
Nuvox Communications



> From: xianwinwin <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <user@struts.apache.org>
> Date: Thu, 3 Jan 2008 15:37:08 -0800 (PST)
> To: <user@struts.apache.org>
> Subject: struts2: interceptor - validation doesn't work :-(
> 
> 
> I've been struggling with this issue for a while and any pointer would be
> appreciated.
> 
> I have a simple file with one field -name; I would like to validate that the
> user put information in it.
> 
> I'm using the annotation in order to achieve this but for some reason the
> validation doesn't work (there's no return message that the user did not
> provide the info).
> 
> my file looks like this:
> 
>  
> @RequiredStringValidator(message="name is missing")
> public void setName(String name)
> {
> this.name=name;
> }
> 
> 
> in the jsp page:
> ...
>  <s:textfield name="name" label="your name:" />
> 
> 
> 
> in the xml:
>         <action name="UserTest_*"  method="{1}"
> class="com.simple.validation.Test">
>             <result name="error">/pages/error.jsp</result>
>             <result name="success">/pages/welcome.jsp</result>
>             
>             <interceptor-ref name="guest"/>
>         </action>
> 
> 
> the guest interceptor is:
>             <interceptor-stack name="guest" >
>                 <interceptor-ref name="defaultStack"/>
>             </interceptor-stack>
> 
> any idea?????
> 
> -- 
> View this message in context:
> http://www.nabble.com/struts2%3A-interceptor---validation-doesn%27t-work-%3A-%
> 28-tp14607863p14607863.html
> Sent from the Struts - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


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

Reply via email to