Blogging Roller

Dave Johnson on open web technologies, social software and software development


Erik Hatcher on XDoclet and the Struts Validator.

It's a nice coincidence that the very week that I have to dig into the Struts Validator, two articles appear by Erik Hatcher on XDoclet and Struts. After reading these articles and browsing Matt Raible's AppFuse project code, I was able to fit the pieces together and get XDoclet to generate the right struts-config.xml and validation.xml entries for my form beans. Below are links to Erik's articles and some other resources I found useful in investigating Struts Validation:

Seems like everytime I try to use XDoclet, I have to tweak one of the XDoclet template files to work around a bug. This time was no exception. I found that XDoclet would only generate the right entries in struts-config.xml if my form beans extend ActionForm, but to use the Struts Validator, I need my form beans to extend ValidatorForm. The only way I found to get around this problem was to copy struts_config_xml.xdt out of the XDoclet xdoclet-apache-module-1.2b4.jar file and to change the first forAllClasses like so (my change in bold):

  <!-- ========== Form Bean Definitions ============== -->
  <form-beans>
<XDtClass:forAllClasses type="org.apache.struts.validator.ValidatorForm"> <XDtClass:forAllClassTags tagName="struts:form" superclasses="false"> <form-bean name="<XDtClass:classTagValue tagName="struts:form" paramName="name"/>" type="<XDtClass:fullClassName/>" /> </XDtClass:forAllClassTags> </XDtClass:forAllClasses>

I believe there needs to be one of those forAllClassses loops for each type of form: ActionForm, ValidatorForm, and ValidatorActionForm. This does not appear in the current XDoclet CVS for <a href= "http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/xdoclet/xdoclet/modules/apache/src/xdoclet/modules/apache/struts/resources/struts_config_xml.xdt?rev=1.11&content-type=text/vnd.viewcvs-markup"> struts_config_xml.xdt. My chance to get a patch in?

Tags: Java

Main | Next day (Aug 2, 2003) »