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;
    }

I fear I'll probably have to rewrite xml*fieldvalidator for other validator
types.

If you can think of a better alternative, let me know.

Cheers,
Josep

2011/11/30 Łukasz Lenart <lukasz.len...@googlemail.com>

> 2011/11/30 Josep García <jgar...@isigma.es>
>
> > This way, it works, but the downside: 149 line source file to work around
> > the problem.
> >
>
> Could you prepare a patch and label it with 3.x ? Maybe we'll be able to
> refactor the manager with your changes
>
>
> Kind regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
> Warszawa JUG conference - Confitura http://confitura.pl/
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to