View Full Version : Cannot find validator-rules.xml
garyfisher
Jun 2nd, 2005, 04:25 AM
Hi,
I must be missing something. I try to integrate Validator into my webapp, but everyone talks about the validator-rules.xml file, but I cannot find it neither in Spring modules distribution nor in Commons Validator distribution.
And I know it's necessary to have a Spring specific one due to FieldChecks class. Where can I find a good file? I've found only the example from Spring Live and it's an old version (1.0) containing JavaScript in it.
Thanks
Pavel
robh
Jun 2nd, 2005, 08:40 AM
Pavel,
We're all using the same file ;)
We are going to be including a more up-to-date file in the 0.3 release of Spring Modules. Time pressure prevented us from getting this into the 0.2 release.
Rob
garpinc2
Nov 2nd, 2005, 10:18 PM
Will you have url validator in 0.3?
Beulah
Nov 16th, 2005, 05:07 PM
Hi,
I followed all the rules given to add common validator to the spring programs i have already written, It works fine when I have only one depends in my validation.xml for a property.
<field property="firstName" depends="required" and it shows me the correct validation error. But whenever I enter another validation for the same property as given below:
<form-validation>
<formset>
<form name="registration">
<field property="firstName" depends="required,mask">
<arg0 key="registrationForm.firstname.displayname"/>
<var>
<var-name>mask</var-name>
<var-value>^[a-zA-Z]$</var-value>
</var>
</field>
</form>
</formset>
</form-validation>
First time the error comes properly if I dont enter anything in the firstname field. But when i do enter anything then I think it tries to check the mask validation and gives the below error:
15:50:51,282 ERROR [Validator] reflection: null
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.j
ava:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.commons.validator.Validator.executeVali dationMethod(Validator.java:
514)
at org.apache.commons.validator.Validator.validateFie ldForRule(Validator.java:424
)
at org.apache.commons.validator.Validator.validateFie ld(Validator.java:669)
at org.apache.commons.validator.Validator.validate(Va lidator.java:745)
at org.springmodules.commons.validator.AbstractBeanVa lidator.validate(AbstractBea
nValidator.java:49)
at org.springframework.validation.ValidationUtils.inv okeValidator(ValidationUtils
.java:57)
at org.springframework.web.servlet.mvc.BaseCommandCon troller.bindAndValidate(Base
CommandController.java:302)
at org.springframework.web.servlet.mvc.AbstractFormCo ntroller.handleRequestIntern
al(AbstractFormController.java:242)
at org.springframework.web.servlet.mvc.AbstractContro ller.handleRequest(AbstractC
ontroller.java:128)
at org.springframework.web.servlet.mvc.SimpleControll erHandlerAdapter.handle(Simp
leControllerHandlerAdapter.java:44)
at org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet
.java:684)
at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.
java:625)
at org.springframework.web.servlet.FrameworkServlet.s erviceWrapper(FrameworkServl
et.java:386)
at org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:
355)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFi
lterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChai
n.java:157)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(ReplyHeaderFilter.java
:75)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFi
lterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChai
n.java:157)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java
:214)
at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.
java:104)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invo keInternal(StandardContextVa
lve.java:198)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java
:152)
at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.
java:104)
at org.jboss.web.tomcat.security.CustomPrincipalValve .invoke(CustomPrincipalValve
.java:66)
at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.
java:102)
at org.jboss.web.tomcat.security.SecurityAssociationV alve.invoke(SecurityAssociat
ionValve.java:150)
at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.
java:102)
at org.jboss.web.tomcat.security.JaccContextValve.inv oke(JaccContextValve.java:54
)
at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.
java:102)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.
java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.
java:102)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:1
09)
at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.
java:104)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(Co yoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.processConnect
ion(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(P oolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:
683)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.NoClassDefFoundError: org/apache/oro/text/perl/Perl5Util
at org.apache.commons.validator.GenericValidator.matc hRegexp(GenericValidator.jav
a:119)
at org.springmodules.commons.validator.FieldChecks.va lidateMask(FieldChecks.java:
213)
My validator.jsp contains:
<%@ page language="java" contentType="javascript/x-javascript" %>
<%@ taglib uri="http://www.springmodules.org/tags/commons-validator"
prefix="html" %>
<html:javascript dynamicJavascript="false" staticJavascript="true"/>
Registration.jsp
<form method="post" action="<c:url value="/registration.htm"/>" onsubmit="return validateUser(this)">
<% System.out.println(" beginning of post "); %>
<table border="0" width="100%">
<tr>
<% System.out.println(" I am inside before firstname in registration"); %>
<th align="left">
<fmt:message key="registrationForm.firstname.displayname"/>
</th>
<td align="left">
<spring:bind path="registration.firstName">
<input type="text" name="<c:out value="${status.expression}" />" value ="<c:out value="${status.value}" />" />
<span class="fieldError"><c:out value="${status.errorMessage}" /></span>
</spring:bind>
</td>
</tr>
<tr>
<td>
<% System.out.println(" I am inside before submit in registration"); %>
<input type="submit" name="bookdetails" value="Save">
</td>
</tr>
</table>
</form>
<html:javascript formName="registration"
staticJavascript="false" xhtml="true" cdata="false"/>
<script type="text/javascript"
src="<c:url value="/scripts/validator.jsp"/>"></script>
</body>
</html>
springapp-servlet.xml
<bean id="beanValidator" class="org.springmodules.commons.validator.DefaultBeanVal idator">
<property name="validatorFactory" ref="validatorFactory"/>
</bean>
<bean id="registration" class="spring.RegistrationController">
<property name="commandName" value="registration"/>
<property name="validators" ref="beanValidator"/>
<property name="commandClass"><value>spring.pojo.Registration</value></property>
<property name="formView"><value>Registration</value></property>
<property name="successView"><value>protected/orderHome.htm</value></property>
</bean>
application-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="registerValidator" class="spring.validator.RegisterValidator">
</bean>
<bean id="validatorFactory" class="org.springmodules.commons.validator.DefaultValidat orFactory">
<property name="validationConfigLocations">
<list>
<value>/WEB-INF/validator-rules.xml</value>
<value>/WEB-INF/validation.xml</value>
</list>
</property>
</bean>
</beans>
web.xml
<display-name>springapp</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListe ner</listener-class>
</listener>
I have been looking into this for a long time. I would really appreciate a quick response as we have group project delivery in our college. Can it be something to do with the jar files. I have the below jars inside my WEB-INF/lib directory.
springmodules-validator-0.1.jar
commons-validator.jar
spring.jar
JSTL.JAR etc
Thanking you in advance,
Beulah
NicolasPeeters
Feb 3rd, 2006, 03:40 AM
Pavel,
Could you find a good validator-rules.xml in the meantime?
Thx
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.