Results 1 to 4 of 4

Thread: need help with Commons Validator

  1. #1
    Join Date
    Jan 2005
    Posts
    17

    Default need help with Commons Validator

    Somehow I don't get my commons validator to work after I changed my command class.

    I get following error message:

    Code:
    java.lang.IllegalArgumentException: Validator [org.springframework.validation.commons.BeanValidator@1ba5016] does not support command class [example.web.commandObj.UserFormCommand]
    validation.xml:
    Code:
    <form-validation>
    	<formset> 
    		<form name="user"> 
    			<field property="username" depends="required"> 
    				<arg0 key="user.user.username"/> 
    			</field> 
    		</form>
    	</formset> 
    </form-validation>
    action-servlet.xml:
    Code:
    <bean id="userFormController" class="example.web.UserFormController"> 
    		<!--  optional - if you don't define it then the default name is command -->
    		<property name="commandName">
    			<value>user</value>
    		</property> 
    		<property name="commandClass"> 
    			<value>example.web.commandObj.UserFormCommand</value> 
    		</property> 
    		<property name="formView">
    			<value>userForm</value>
    		</property> 
    		<property name="successView">
    			<value>showUser.html</value>
    		</property> 
    		<property name="userManager">
    			<ref bean="userManager"/>
    		</property> 
    		<property name="validator">
    			<ref bean="beanValidator"/>
    		</property>
    	</bean>

    the jsp file:

    Code:
    <form name="user" method="post" action="<c&#58;url value="/showAddUser.html"/>" onsubmit="return validateUser&#40;this&#41;"> 
    	<table> 
    		<tr> 
    			<th>
    				<fmt&#58;message key="user.username"/>&#58; 
    			</th> 
    			<td> 
    				
    				<spring&#58;bind path="user.user.username">
    	               <input type="text" name="$&#123;status.expression&#125;" value="<c&#58;out value="$&#123;status.value&#125;"/>">
    	               <span class="fieldError">$&#123;status.errorMessage&#125;</span>
    	            </spring&#58;bind>
    			</td>
    			&#91;...&#93;
    I already found a similar problem in the forum but I still haven't figured out what the problem is

  2. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    It is likely that validation.xml is not used by the DefaultValidatorFactory or you are referencing an old version. Could you please double check that the referenced validation.xml file contains a definition for "user".
    HTH
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  3. #3
    Join Date
    Jan 2005
    Posts
    17

    Default

    Quote Originally Posted by irbouho
    It is likely that validation.xml is not used by the DefaultValidatorFactory or you are referencing an old version. Could you please double check that the referenced validation.xml file contains a definition for "user".
    HTH
    I checked it ... and it is there and the validation.xml is the only version!

    <bean id="validatorFactory"
    class="org.springframework.validation.commons.Defa ultValidatorFactory" init-method="init">
    <property name="resources">
    <list>
    <value>/WEB-INF/validator-rules.xml</value>
    <value>/WEB-INF/validation.xml</value>
    </list>
    </property>
    </bean>

  4. #4
    Join Date
    Aug 2004
    Location
    Atlanta, GA
    Posts
    129

    Default

    Your form name in validation.xml should be "userFormCommand" rather than "user" to match your command class (but w/lowercase first letter.

    The C-V naming convention is pretty icky. <form> is actually referring to the classname, not the object name.

    HTH
    Randy

Similar Threads

  1. Replies: 1
    Last Post: Oct 6th, 2005, 06:44 AM
  2. Replies: 3
    Last Post: Apr 5th, 2005, 09:20 PM
  3. Replies: 2
    Last Post: Nov 25th, 2004, 03:41 PM
  4. Replies: 1
    Last Post: Nov 25th, 2004, 11:08 AM
  5. Commons Validator integration
    By sjivan in forum Web
    Replies: 3
    Last Post: Oct 14th, 2004, 04:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •