xdoclet springvalidationxml does not parse validator on setters of classes

Dimitris Kapanidis <[email protected]>
Newsgroups gmane.comp.java.xdoclet.user
Message-ID <[email protected]>
Hello,

I have a question about some restrictions in the springvalidationxml.
I have a setter in a class that is passing as a parameter a Message 
object (Message is a class of mine).
User.java
...
    /**
     * @param name
     *            The name to set.
     * @spring.validator type="messageRequired"
     */
    public void setName(Message name) {
        this._name = name;
    }

What I want as a result is the following, (messageRequired is a custom 
Validator and is working perfectly with this result):
validation.xml:
...
      <form name="user">
              <field property="name"
                     depends="messageRequired">

                  <arg0 key="user.name"/>
              </field>
      </form>


But I cannot get this output unless the setter is a String. I know that 
I can use recursion if I put "@spring.validator" to the setName setter, 
and then "@spring.validator type="required" to a string setter in the 
Messages, but even like that my problem still exists because I don't 
have a String setter but a Map setter (which is not parsed by xdoclet).

I do not understand why the setter is restricted to String, as custom 
Validators cannot be used this way. Can I change this restriction by 
using a custom template? I saw the original one but I don't understand 
how to add this functionality. Can anyone give me an advice? I would 
really appreciate some help.

dimitris

------------------------------
I don't think the following is necessary but I've added for giving a 
bigger picture.

The message contains the following setter only (there is no String 
setter, a Map is used because the number of fields is not known on 
compilation):

Message.java:
...
    /**
     * @param _localizedMessages
     *            The _localizedMessages to set.
     */
    public void setLocalizedMessages(Map localizedMessages) {
        this._localizedMessages = localizedMessages;
    }


I am running webdoclet on build.xml with the following code:
build.xml:
...
<webdoclet destdir="${organizer.common.dir}/WEB-INF" 
mergedir="${conf.dir}/metadata" force="${xdoclet.force}" 
excludedtags="@version,@author" verbose="true">
            <fileset dir="${src.dir}">
                <include name="**/*.java" />
            </fileset>
            <springvalidationxml/>
</webdoclet>
...

I have a custom validator in validator-custom-rules:
validator-custom-rules.xml:
...
        <validator name="messageRequired"
            classname="com.company.common.utils.validation.ValidationUtils"
               method="validateMessageRequired"
          methodParams="java.lang.Object,
                               org.apache.commons.validator.ValidatorAction,
                               org.apache.commons.validator.Field,
                               org.springframework.validation.Errors"
                  msg="errors.messageRequired">
      </validator>

Here is my custom Validator:
ValidationUtils.java:
...
    public static boolean validateMessageRequired(Object bean, 
ValidatorAction va,
            Field field, Errors errors) {

       // getValueAsMessage is returning the Property object as a Message
        Message message = getValueAsMessage(bean, field.getProperty());

        return rejectMessageIfEmptyOrBlank(errors, field.getProperty(), 
message);
    }


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.