Friday, October 15, 2004
Validator: Using A ValidWhen Edit
I was receiving a server error after adding a "validwhen" edit to my validation.xml file that looked like the following.
<field property="employmentHistoryDate" depends="validwhen">
<msg name="validwhen" key="error.employee.employmentHistoryDate.blank">
<var>
<var-name>test</var-name>
<var-value>((employeeHistory == "C") or (*this* == null))</var-value>
</var>
</msg>
</field>
</code>
I thought that my syntax was incorrect so I spent some time reviewing the information on the Validator website for the validwhen edit.
http://struts.apache.org/userGuide/dev_validator.html
After adding an edit to my validation.xml that was a carbon copy of an example in the userGuide and still receiving the excetpion I realized that there must be something else going on. I noticed a reference in the first line of the exception that had the name "antlr". I did a search for Validator and "antlr" and I came across a JavaRanch message that said that you must have the "antlr.jar" file in your "lib" folderif you wish to use "validwhen". I then searched and found the "antlr" website at www.antlr.org and downloaded the "antlr" .zip file and placed antlr.jar in my lib folder. Now my "Validwhen" edits work like a charm.
More Info on ANTLR below and on the website.
ANTLR Parser Generator and Translator Generator Home Page
ANTLR Parser Generator and Translator Generator Home Page: "ANTLR, ANother Tool for Language Recognition, (formerly PCCTS) is a language tool that provides a framework for constructing recognizers, compilers, and translators from grammatical descriptions containing Java, C#, or C actions. ANTLR provides excellent support for tree construction, tree walking, and translation. There are currently about 5,000 ANTLR source downloads a month. "
