开发者

Struts2 conditional validation

Is it possible in Struts 2 to avoid several validations (defined as anotations) depending on the value of a given field? Something like: "if radiobutton has value x do not validate fields a, b and c".

This would be useful to me since I'm developing a JSP page (model driven) and I'm not showing all the fields at the same time, the visible ones depend on a radiobutton value. However, when submiting, the validators from the hidden fields are开发者_如何学编程 "activated" and the validation process fails. So, I want to to ignore the hidden ones, is there a way to do this?

Thanks!


I do this using OGNL and the expression validator Apache Struts 2 Documentation

I do this using xml because IMHO annotations are a bit intrusive, and rather not use them everywhere. But you sure can use the annotation version Validation Annotation.

Hope it helps...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜