If I pass in a dynamic context name, like in
validatorManager.validate(this, "my-validation"), the
AnnotationActionValidator calls its method getValidators:
public synchronized List<Validator> getValidators(Class clazz, String
context, String method) {
final String validatorKey = buildValidatorKey(clazz);
if (validatorCache.containsKey(validatorKey)) {
if (FileManager.isReloadingConfigs()) {
validatorCache.put(validatorKey,
buildValidatorConfigs(clazz, context, true, null));
}
} else {
validatorCache.put(validatorKey, buildValidatorConfigs(clazz,
context, false, null));
}
// get the set of validator configs
List<ValidatorConfig> cfgs = validatorCache.get(validatorKey);
and if reload is false, it will not find the file
MyAction-my-validation-validation.xml: the validatorKey is based on the
clazz name, and not on the context.
:-(
Any suggestion about this?
J.
2011/11/28 Łukasz Lenart <[email protected]>
> 2011/11/28 Josep García <[email protected]>:
> > I have tried this option, not without a few workarounds: I had to add a
> > param to struts.xml so validation files are loaded during runtime:
> > <constant name="struts.configuration.xml.reload" value="true"/>
>
> Hmmm.... that's bad, each time the configs will be reload from the
> disk and performance of the application will decrease :/
>
> > I have arrived to a leve in which I can call, from my Action:
> >
> > validatorManager.validate(this, "my-validation");
> >
> > and this tries to validate the form against a MyAction-my-validation.xml
> > file with the validation rules.
> > So far, so good.
> > However, my form post the user input as form parameters of the type:
> > "dom.myparam1", "dom.myparam2", etc.
> > Within the validation process, the validator calls OgnlContext.get(Object
> > key) to retrieve the value to validate agains a validation rule, but
> fails
> > to retrieve it.
> > While debugging, I can see the params are there in a map entry: Key:
> > "com.opensymphony.xwork2.ActionContext.parameters", and in value: all my
> > form params.
> > buut it fails to get the value.
> >
> > Any possible workaround for this? Can I make OgnlContext look into the
> > ActionContext.parameters map? Or should I add programatically my dynamic
> > fields to the Ognl Context? Is that possible? How?
>
> OGNL should search through out the stack, maybe try to put those
> parameters on top ?
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
> Warszawa JUG conference - Confitura http://confitura.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>