2 Replies Latest reply on Nov 3, 2005 12:39 AM by Paul Marando

    Seam and <h:inputtext validator..

    Paul Marando Newbie

      G'day

      First let me say that I am really impressed by Seam and even though I have only been playing with it for a few days I have decided to take the plunge and use it in production *GASP*.

      Next, I am having some problems with validation methods in backing beans. Overall I assume I will use hibernate validation for most of the work, but occasionally there will be some businessy testing that won't fit. for example in the hotel booking example checking that the username doesn't exist.

      So to use the backing beans method I change one line of code in register.xhtml to

      <h:inputText id="name" value="#{user.name}" validator="#{register.validateUsername}"/>


      Then I add the method to RegisterAction.Java

      public void validateUsername(FacesContext context, UIComponent toValidate, Object value)
      {
      ..
      }


      Apart from an import that is ALL I changed.

      What I get is the following exception:
      15:11:48,014 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
      javax.faces.el.MethodNotFoundException: /register.xhtml @41,112 validator="#{register.validateUsername}": Method not found: org.jboss.seam.example.booking.RegisterAction:5c4o17-o1resp-efkgw7gz-1-efkiwk32-j.validateUsername(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.Object)
       at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:71)
       at javax.faces.component._ComponentUtils.callValidators(_ComponentUtils.java:152)
       at javax.faces.component.UIInput.validateValue(UIInput.java:254)
       at javax.faces.component.UIInput.validate(UIInput.java:269)
       at javax.faces.component.UIInput.processValidators(UIInput.java:144)
       at javax.faces.component.UIForm.processValidators(UIForm.java:68)
       at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:417)
       at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:142)
       at org.apache.myfaces.lifecycle.LifecycleImpl.processValidations(LifecycleImpl.java:208)
       at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:76)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:94)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      


      Now it seems to lookup the method name correctly from "register.validateUsername" but it seems to have some problems finding the code. Jar related?

      I have not spent too much time on this (with deadlines and all) but I was curious to know what I needed to change to get this to work, obviously this is not critical because the work around is to leave it like it was, but I like the concept of putting a validator with the inputtext.

      Cheers

      Paulie