There was interest earlier on the list for an XDoclet module to automatically generate the XWork *-validation.xml files. I've put together a module that you can use in your XWork/WebWork2 projects. The attached zip file contains the module jar file, an example class marked up with tags and the generated validation.xml file.
 
Here is an example of the tag usage:
 
/**
 * @xwork.field name="created"
 * @xwork.field-validator.required message="created is a required field."
 * @xwork.field-validator.date-range
 *      min="12-22-2002"
 *      max="12-25-2002"
 *      message="The date must be between 12-22-2002 and 12-25-2002."
 */
 private Date created;
 
To add this to your build process add the following task (or similar) to your build.xml file:
 
<target name="generate" depends="setenv">
    <taskdef
        name="xworkdoclet"
        classname="xdoclet.modules.xwork.XWorkDocletTask"
        classpathref="classpath"
    />
 
    <xworkdoclet
        destdir="${build.dest}"
        excludedtags="@version,@author"
    >
        <fileset dir="${java.dir}">
            <include name="**/*.java"/>
        </fileset>
 
        <xwork />
    </xworkdoclet>
</target>
 
You will need to add the xdoclet-xwork-module-1.2b4.jar file along with the xdoclet-1.2b4.jar file to your build env classpath.
 
Feedback is appreciated.
 
- Brock

Attachment: xwork-mod.zip
Description: Binary data

Reply via email to