Struts 2 and WebWork: Validator XML Syntax Trivia
I had to write a validator to check if a date entered in a form is not one in the future. I could not find an example of this in the documentation, and had to search around a bit to figure out the right XML syntax.
<validators>
<field name="someDate">
<field-validator type="fieldexpression">
<param name="expression"><![CDATA[!someDate.isAfter(@com.domainlanguage.timeutil.Clock@today())]]></param>
<message>Please enter a date on or before today</message>
</field-validator>
</field>
</validators>
Notice the ‘@’s. Posting this here for anyone who might find it helpful. 🙂
PS: We use Eric Evans’ timeandmoney package.
Categories: tech
Since the S2 documentation is a wiki, I added a link to this page as a comment.
-Ted.