David Newton wrote:Still don't know your usecase, so I can't really help. Expressions in the expression validator can be arbitrary OGNL, AFAIK, and OGNL can call arbitrary Java.
That said, for anything other than trivial validations, I almost always do it in Java code anyway, for clarity, code completion, type safety, and so on.
I had done some experiments on validation.
At last, I found that fieldexpression is what I want to use.
<field name="items">
<field-validator type="fieldexpression">
<param name="expression"><![CDATA[
items.size()>0]]></param>
<message key="items.blank.message"/>
</field-validator>
</field>
but this doesn't work!
<field name="items">
<field-validator type="fieldexpression">
<param name="expression"><![CDATA[
#items.size()>0]]></param>
<message key="items.blank.message"/>
</field-validator>
</field>
What is the purpose of this Shape(#) for?
The official doc:
http://struts.apache.org/2.1.8.1/docs/fieldexpression-validator.html
This really confuses me a lot!
And, I still don't accept the validation is not in intuitive logic.
I'd prefer the <param> requires a TRUE for triggering the message.
Though I can customize my own validator.