1 Reply Latest reply on Apr 10, 2010 7:00 PM by Ignacio Larrañaga

    NPE s:validateEquality with readonly fields

    Ignacio Larrañaga Newbie

      Hi, I have a problem with s:validateEquality and readonly h:inputText, this is the sample code:


      <a4j:region>
           <s:decorate id="creditValueFieldId" template="/layout/edit.xhtml">
                <ui:define name="label"><h:outputText value="#{messages['UserMovement.credit']}"/></ui:define>
                <h:inputText id="creditValueId" required="true" value="#{userMovement.credit}" readonly="true" />
           </s:decorate>
           <s:decorate id="valueFieldId" template="/layout/edit.xhtml">
                <ui:define name="label"><h:outputText value="#{messages['UserMovement.value']}"/></ui:define>
                <h:inputText id="valueId" required="true" value="#{userMovement.value}">
                     <s:validateEquality for="creditValueId" operator="less_or_equal" message="#{messages['Withdraw.not_enough_credit']}" />
                     <a4j:support event="onchange" eventsQueue="default" reRender="valueFieldId,withdrawId"/>
                </h:inputText>
                <ui:param name="description" value="#{messages['Withdraw.value_must_be_le_credit']}" />
           </s:decorate>
      </a4j:region>



      When I change the value (onchange event on creditValueId) I get this exception:


      13:47:30,218 ERROR [Exceptions] handled and logged exception
      javax.servlet.ServletException: java.lang.IllegalArgumentException: Values are not comparable
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
           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.web.IdentityFilter.doFilter(IdentityFilter.java:40)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
           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:45)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
           at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
           at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
           at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
           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:235)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
           at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
           at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
           at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
           at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
           at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
           at java.lang.Thread.run(Unknown Source)
      Caused by: javax.faces.FacesException: java.lang.IllegalArgumentException: Values are not comparable
           at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:714)
           at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:675)
           at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:720)
           at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:675)
           at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:720)
           at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:675)
           at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:720)
           at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:675)
           at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:226)
           at org.ajax4jsf.component.AjaxViewRoot.processValidators(AjaxViewRoot.java:463)
           at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
           at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
           at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
           ... 41 more
      Caused by: java.lang.IllegalArgumentException: Values are not comparable
           at org.jboss.seam.ui.validator.EqualityValidator.compare(EqualityValidator.java:202)
           at org.jboss.seam.ui.validator.EqualityValidator.validate(EqualityValidator.java:141)
           at org.richfaces.component.UIRichInput.validateInput(UIRichInput.java:44)
           at org.richfaces.component.html.HtmlInputText.validateValue(HtmlInputText.java:46)
           at javax.faces.component.UIInput.validate(UIInput.java:875)
           at javax.faces.component.UIInput.executeValidate(UIInput.java:1072)
           at javax.faces.component.UIInput.processValidators(UIInput.java:672)
           at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1058)
           at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1058)
           at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1058)
           at org.ajax4jsf.component.UIAjaxRegion.processValidators(UIAjaxRegion.java:121)
           at org.ajax4jsf.component.AjaxViewRoot$3.invokeContextCallback(AjaxViewRoot.java:447)
           at org.ajax4jsf.component.ContextCallbackWrapper.invokeContextCallback(ContextCallbackWrapper.java:44)
           at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:711)
           ... 54 more
      Caused by: java.lang.NullPointerException
           at java.lang.Double.compareTo(Unknown Source)
           at java.lang.Double.compareTo(Unknown Source)
           at org.jboss.seam.ui.validator.EqualityValidator.compare(EqualityValidator.java:198)
           ... 67 more



      The courious thing is that when I remove the readonly mark in the first field (creditValueFieldId) the exception dissapears :). That is:


      <h:inputText id="creditValueId" required="true" value="#{userMovement.credit}" />



      Any idea ?