struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Susan Bradeen" <Sus...@softlanding.com>
Subject RE: DynaValidatorForm with validate()
Date Wed, 29 Jan 2003 20:04:31 GMT
Thank you, Sri!

Susan Bradeen
SoftLanding Systems, Inc
susanb@softlanding.com





"Sri Sankaran" <Sri.Sankaran@sas.com>
01/29/2003 02:47 PM
Please respond to "Struts Users Mailing List"

 
        To:     "Struts Users Mailing List" <struts-user@jakarta.apache.org>
        cc: 
        Subject:        RE: DynaValidatorForm with validate()


Did you try setting the type attribute of the <form-bean> to 
full.qualified.ProfileForm?

Sri

> -----Original Message-----
> From: Susan Bradeen [mailto:SusanB@softlanding.com] 
> Sent: Wednesday, January 29, 2003 2:44 PM
> To: struts-user@jakarta.apache.org
> Subject: DynaValidatorForm with validate()
> 
> 
> Can you override (or supplement?) a DynaValidatorForm with a 
> form bean, 
> and use the validate() method along with the validations 
> specified in the 
> validation.xml? I can display my validation.xml errors, but 
> not any from 
> my validate() method. It appears to bypass it and go right to the 
> 'success' page. Seems like this should work, but obviously I 
> am missing 
> something. 
> 
> I have a DynaValidatorForm and a "form bean" and action mapping as 
> follows:
> 
> <form-bean
>   name="profileform"
>   type="org.apache.struts.validator.DynaValidatorForm">
>   <form-property
>     name="userName"
>     type="java.lang.String" />
>   <form-property
>     name="password"
>     type="java.lang.String" />
>   <form-property
>     name="confirmPassword"
>     type="java.lang.String" />
>   ...
> </form-bean>
> 
> public class ProfileForm extends DynaValidatorForm {
>   public ProfileForm() {
>     super();
>   }
> 
>   public ActionErrors validate(ActionMapping mapping, 
> HttpServletRequest request) 
> {
>     ActionErrors errors = super.validate(mapping, request);
>     if (errors == null) {
>        errors = new ActionErrors();
>     }
> 
>     String pw = (String)this.get("password");
>     String cpw = (String)this.get("confirmPassword");
> 
>     if (!(pw.equals(cpw))) {
>         errors.add(ActionErrors.GLOBAL_ERROR, new 
> ActionError("error.validate.password"));
>     }
> 
>     if (errors.isEmpty()) {return null;}
>     return (errors);
>   } 
> }
> 
> 
> <action
>    path="/savenewprofile"
>    type="com.etc.actions.RegisterPostAction"
>    name="profileform"
>    scope="request"
>    input=".register"
>    validate="true">
>    <forward name="success" path=".login"/>
>    <forward name="cancel" path=".main"/>
> </action>
> 
> 
> Any suggestions? 
> 
> Susan Bradeen
> SoftLanding Systems, Inc
> susanb@softlanding.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message