You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Ryan Keeling <ry...@aepona.com> on 2006/04/27 16:21:14 UTC

Selective Validation

Hi guys,
I have a commons validator question - I am autogenerating all my pojos 
using xdoclet I can add the validator tags to the xdt so they will be 
applied to all the setters, this is an example output which is great.

   /**
   * Setter method for objectClass
   * @spring.validator type="required"
   * @spring.validator type="mask" msgkey="errors.objectClass"
   * @spring.validator-var name="mask" value="${objectClass}"
   */
   public void setObjectClass(java.lang.String objectClassvalue){
       this.objectClass = objectClassvalue;
   }

When I run the webdoclet task this is successfully put into 
validation.xml, the problem is that not all the fields in my JSP are 
required, I dont even display them so they are never submitted. My 
question is can I get commons validator to only validate submitted 
fields and not try and validate the entire form in validation.xml

If for example I have the following in validation.xml but I only wanted 
to submit city and ignore everything else for that form - is this 
possible? Hope I have explained this so you understand ;-)

     <form name="address">
             <field property="city"
                    depends="required">
                <arg0 key="address.city"/>
             </field>
             <field property="country"
                    depends="required">
                 <arg0 key="address.country"/>
             </field>
             <field property="province"
                    depends="required">
                 <arg0 key="address.province"/>
             </field>
     </form>


Thanks as ever,
Ryan