struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Łukasz Lenart <lukasz.len...@googlemail.com>
Subject Re: using xwork validator programatically?
Date Thu, 01 Dec 2011 09:49:55 GMT
2011/12/1 Josep García <jgarcia@isigma.es>

> Basically,  validatorKey build from clazz AND context.
>
>         final String validatorKey = buildValidatorKey(clazz, context);
>
> I enclose a patch, with changes relative to xwork-core-2.1.6.
>
>
> In order to validate dynamic form input fields (based on freemarker's
> ability to render input fields from xml tree), I've also had to code my own
> field validator, because my action does not have getter/setter for the
> dynamic fields.
>
> In my derived XmlRequiredFieldValidator, I reimplement getFieldValue:
>
>     protected Object getFieldValue(String name, Object object) throws
> ValidationException {
>         ValidateableXml action = (ValidateableXml) object;
>         Map<String, String[]> params = action.getParameterMap();
>         String[] val = params.get(name);
>         String str = null;
>         if (val != null) {
>             str = val[0];
>             if (str.isEmpty()) {
>                 str = null;
>             }
>         }
>         return str;
>     }



Could you register an issue [1] and attach the patch there with granting
rights to ASF ?

[1] https://issues.apache.org/jira/browse/WW


Thanks in advance
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
Warszawa JUG conference - Confitura http://confitura.pl/

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message