struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Waite <andrew.wa...@gmail.com>
Subject Re: Using Struts Validator on Map-backed ActionForms
Date Sun, 13 Feb 2005 11:30:47 GMT
Niall,

Thanks again for the reply. I am afraid this is not going to work for
me, however.  The problem is I don't see how I can "do nothing
different than normal validation".  Normal validation requires the
field names and validations to be declared in the validation.xml file.
 I do not know in advance what those values will be. :(

If I am missing something let me know but I am just not able to comply
with the validation.xml declaration requirement since I don't know
what to put in the property value:

<form name="myLazyForm">
    <field property="???????????"  depends="required">
        <arg key="myLazyForm.?????????.displayname"/>
    </field>
</form>

Andrew


On Sun, 13 Feb 2005 02:25:04 -0000, Niall Pemberton
<niall.pemberton@blueyonder.co.uk> wrote:
> There isn't anything different you need to do from normal validation.
> 
> http://struts.apache.org/userGuide/dev_validator.html
> 
> The only issue you might hit is if you want to validate according to the
> Action Mapping's path, rather than the form name. Then you would need a
> custom ActionForm - but thats very straight forward. Just extend either
> BeanValidatorForm or LazyValidatorForm and instantiate the LazyDynaMap in
> the constructor and fix the validation key (use setPathValidation(true)
> method) to use the mapping's path. Something like...
> 
> public class MyLazyForm extends LazyValidatorForm() {
>     public MyLazyForm() {
>         super(new LazyDynaMap());
>         setPathValidation(true);
>     }
> }
> 
> Some people don't like using the setPathValidation() because
> BeanValidatorForm automatically removes the leading "/" - if thats the case
> you can just override getValidationKey() method....
> 
>     public String getValidationKey(ActionMapping mapping,
>                                    HttpServletRequest request) {
>          return mapping.getPath();
>     }
> 
> Obviously in your struts-config you need to specify this new form....
> 
>  <form-bean name="mapForm" type="myPackage.MyLazyForm"/>
> 
> Niall
> 
> ----- Original Message -----
> From: "Andrew Waite" <andrew.waite@gmail.com>
> Sent: Saturday, February 12, 2005 10:50 PM
> 
> > Thanks for the response. This is looking promising - excellent work, btw.
> >
> > I have the Action and Struts communicating with this "form".  Do you
> > have any example of how to apply the Validaror against it?  Looking
> > for some samples but given how new this is it's hard to come by.
> >
> > Thanks,
> > Andrew
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

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


Mime
View raw message