[jboss-user] [JBoss Seam] - Re: How to write a validator that compares two fields

chawax do-not-reply at jboss.com
Fri Oct 12 10:03:13 EDT 2007


OK. It was working until now with components.xml in /WEB-INF, but I will follow your recommandation.

I have a new problem with this validator since it is declared as a Seam component and no more in faces-config.xml. It looks like the ValidatorException is not caught !

15:56:56,333 ERROR [ExceptionFilter] handling uncaught exception
  | javax.servlet.ServletException
  | 	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
  | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
  | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  | 	at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:307)
  | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
  | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  | 	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
  | 	at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
  | 	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  | 	at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
  | 	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  | 	at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
  | 	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  | 	at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:44)
  | 	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  | 	at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
  | 	at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
  | 	at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
  | 	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  | 	at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
  | 	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  | 	at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:150)
  | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
  | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  | 	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
  | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
  | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  | 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
  | 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
  | 	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
  | 	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
  | 	at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
  | 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
  | 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
  | 	at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
  | 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
  | 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
  | 	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
  | 	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
  | 	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
  | 	at java.lang.Thread.run(Thread.java:595)
  | Caused by: java.lang.reflect.InvocationTargetException
  | 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  | 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  | 	at java.lang.reflect.Method.invoke(Method.java:585)
  | 	at javassist.util.proxy.RuntimeSupport$DefaultMethodHandler.invoke(RuntimeSupport.java:37)
  | 	at fr.horoquartz.t4.gui.validators.EqualsValidator_$$_javassist_5.validate(EqualsValidator_$$_javassist_5.java)
  | 	at javax.faces.component.UIInput.validateValue(UIInput.java:1013)
  | 	at javax.faces.component.UIInput.validate(UIInput.java:867)
  | 	at javax.faces.component.UIInput.executeValidate(UIInput.java:1065)
  | 	at javax.faces.component.UIInput.processValidators(UIInput.java:666)
  | 	at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1030)
  | 	at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1030)
  | 	at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1030)
  | 	at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1030)
  | 	at org.richfaces.component.UISwitchablePanel.processValidators(UISwitchablePanel.java:219)
  | 	at javax.faces.component.UIForm.processValidators(UIForm.java:229)
  | 	at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1030)
  | 	at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1030)
  | 	at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:662)
  | 	at org.ajax4jsf.component.AjaxViewRoot.access$201(AjaxViewRoot.java:59)
  | 	at org.ajax4jsf.component.AjaxViewRoot$3.invokeRoot(AjaxViewRoot.java:321)
  | 	at org.ajax4jsf.context.JsfOneOneInvoker.invokeOnRegionOrRoot(JsfOneOneInvoker.java:56)
  | 	at org.ajax4jsf.context.AjaxContextImpl.invokeOnRegionOrRoot(AjaxContextImpl.java:173)
  | 	at org.ajax4jsf.component.AjaxViewRoot.processValidators(AjaxViewRoot.java:335)
  | 	at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:100)
  | 	at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
  | 	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
  | 	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
  | 	... 40 more
  | Caused by: javax.faces.validator.ValidatorException: Vous avez saisi deux mots de passe différents !
  | 	at fr.horoquartz.t4.gui.validators.CompareValidator.validate(CompareValidator.java:35)
  | 	at fr.horoquartz.t4.gui.validators.EqualsValidator_$$_javassist_5._d17validate(EqualsValidator_$$_javassist_5.java)
  | 	... 68 more
  | 

EqualsValidator class is annotated with @Validator and it inherits CompareValidator which has the following validate() method :
public void validate(FacesContext context, UIComponent cmp, Object value)
  | 		throws ValidatorException {
  | 	UIInput input = (UIInput) JSFUtils.findComponent(context.getViewRoot(), getCompareTo());
  | 	if (! compare(value, input.getValue())) {
  | 		String message = Messages.instance().get(getMessage());
  | 		throw new ValidatorException(new FacesMessage(message));
  | 	}
  | }

I had a look on the way ModelValidator or FormattedTextValidator are written in Seam sources and saw no difference in the way ValidatorException is thrown. Do you have any idea about this ?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4094598#4094598

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4094598




More information about the jboss-user mailing list