Announcement Announcement Module
Collapse
No announcement yet.
commons Validator - no error messages Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • commons Validator - no error messages

    Hi!

    Im trying to integrate the commons validator. I used Matt Raible's guide (http://www.jroller.com/page/raible/2...or_with_spring) to do it - validation works but I get no error messages. Can anyone tell me what is wrong?

    My action-servlet.xml:

    Code:
    <bean id="validatorFactory" class="org.springframework.validation.commons.DefaultValidatorFactory" init-method="init"> 
    		<property name="resources"> 
    			<list> 
    				<value>/WEB-INF/validator-rules.xml</value> 
    				<value>/WEB-INF/validation.xml</value> 
    			</list> 
    		</property> 
    	</bean> 
    	
    	<bean id="beanValidator" class="org.springframework.validation.commons.BeanValidator"> 
    		<property name="validatorFactory"> 
    			<ref local="validatorFactory"/> 
    		</property> 
    	</bean>
    
    
    <bean id="userFormController" class="exsample.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>exsample.model.User</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>
    jsp page
    Code:
    &#91;...&#93;
    <tr> 
    			<th>
    				<fmt&#58;message key="user.username"/>&#58; 
    			</th> 
    			<td> 
    				<spring&#58;bind path="user.username"> 
    					<input type="text" name="username" value="$&#123;user.username&#125;"/> 
    					<span class="fieldError">$&#123;status.errorMessage&#125;</span> 
    				</spring&#58;bind> 
    			</td>
    &#91;...&#93;
    			
    		</tr>
Working...
X