This is my attempt to make the Hibernate Validator play nicely with WebWork? (and presumably Struts 2 although that hasn't been tested). The validator is basically a copy of the VisitorFieldValidator? that ships with WebWork?.

Get The Code

It's all of one file, so I haven't bothered making a JAR. Just drop in the appropriate package in your source tree.

Other Things You'll Need

  • Hibernate Core and Annotation JARs (http://www.hibernate.org/6.html)
  • validators.xml in your classpath referencing this validator. I've got a sample that I use, but you may want to pull the latest validators.xml file from your WebWork? distribution and just add the custom validator line to it.

How to Use

1 Annotate your domain classes using the Hibernate's built in validators or your own custom validators. 2 Create the WebWork? validation xml file for your action and add something like this to it to have your domain object validated (in this example the property being validated is "issue"):

        <field name="issue">
          <field-validator type="hibernate">
              <param name="appendPrefix">true</param>
              <message></message>
          </field-validator>
        </field>

3 Hmm, there is not step three. Enjoy!