6 Replies Latest reply on Oct 7, 2009 11:19 AM by Olly Edgell

    Conversion errors writing h:selectBooleanCheckbox to boolean property within ui loop

    Olly Edgell Newbie

      Afternoon All,


      I have a seam entity ejb  containing a list of sub-entities, the sub-entity has a boolean property. The user can add to this list of sub-entites which creates a new tab in a tab panel that holds a form, the boolean property is represented with a h:selectBooleanCheckbox.


      The problem I am experiencing only occurrs when the checkbox is held within an iteration tag. I have tried c:forEach, a4j:repeat and ui:repeat with no success. When I submit the form I get the following error:




      *SEVERE [lifecycle] JSF1054: (Phase ID: UPDATE_MODEL_VALUES 4, View ID: /candidateRegPageFlow/acquireExperience.xhtml) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@c63833]*





      Examing the debug page gives this additional error message:



      *Caused by javax.servlet.ServletException with message: "Cannot convert 0 of type class java.lang.Long to class java.lang.Boolean"*







      I realise this may appear to be a mapping problem but I have carried out tests writing this property to the database with no surrounding loop and its fine, leading me to believe this is where the error lies.


      The xhtml fragment:




      <c:forEach items="#{acquireExperienceCR.candidateExperienceList}"                              
                                                      var="experience"
                                                      varStatus="rowCounter">
      
      
      <s:decorate template="../layout/edit.xhtml">
                      <ui:define name="label">Rullion Assignment?</ui:define>
                                      <h:selectBooleanCheckbox 
                                                
                                              value="#{experience.rullionAssignment}">                                                                     
                              </h:selectBooleanCheckbox>                 
                  </s:decorate>
      </c:forEach>





      Any guidance would be much appreciated.

        • 1. Re: Conversion errors writing h:selectBooleanCheckbox to boolean property within ui loop
          Nikos Paraskevopoulos Novice

          Hello,


          The <h:selectBooleanCheckbox> expects its value to be of type Boolean (or boolean). There is a static type cast somewhere in the code.


          What is the type of #{experience.rullionAssignment}? It is probably Long, according to the error message.

          • 2. Re: Conversion errors writing h:selectBooleanCheckbox to boolean property within ui loop
            Olly Edgell Newbie

            Hi,


            You would expect that, but the type is Boolean: -


            @Column(name = "RullionAssignment")
                 @Type(type="yes_no")
                 public Boolean getRullionAssignment() {
                      return this.rullionAssignment;
                 }
            
                 public void setRullionAssignment(Boolean rullionAssignment) {
                      this.rullionAssignment = rullionAssignment;
                 }



            I can't think where it would be considered to be of type long, stranger still it only happens from within ui:repeat, c:forEach and a4j:repeat.

            • 4. Re: Conversion errors writing h:selectBooleanCheckbox to boolean property within ui loop
              Olly Edgell Newbie

              This is the full stacktrace from the seam debug page, the only message output to the log is the JSF 1054 message as stated earliar.




              Exception during request processing:
              Caused by javax.servlet.ServletException with message: "Cannot convert 0 of type class java.lang.Long to class java.lang.Boolean"
              
              javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
              org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
              org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
              org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
              org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
              org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
              org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
              org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
              org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
              org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
              org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
              org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
              org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
              org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
              org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
              org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
              org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
              org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
              org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
              org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
              org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
              org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
              org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
              java.lang.Thread.run(Thread.java:619)
              
              Caused by java.lang.IllegalArgumentException with message: "Cannot convert 0 of type class java.lang.Long to class java.lang.Boolean"
              
              org.jboss.el.lang.ELSupport.coerceToBoolean(ELSupport.java:177)
              org.jboss.el.lang.ELSupport.equals(ELSupport.java:113)
              org.jboss.el.parser.AstEqual.getValue(AstEqual.java:23)
              org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
              com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
              javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:390)
              javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1073)
              javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1081)
              org.ajax4jsf.component.UIAjaxForm.processUpdates(UIAjaxForm.java:98)
              org.ajax4jsf.component.AjaxViewRoot$2.invokeContextCallback(AjaxViewRoot.java:416)
              org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:238)
              org.ajax4jsf.component.AjaxViewRoot.processUpdates(AjaxViewRoot.java:432)
              com.sun.faces.lifecycle.UpdateModelValuesPhase.execute(UpdateModelValuesPhase.java:78)
              com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
              com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
              javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
              org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
              org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
              org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
              org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
              org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
              org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
              org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
              org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
              org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
              org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
              org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
              org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
              org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
              org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
              org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
              org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
              org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
              org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
              org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
              org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
              org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
              org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
              org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
              java.lang.Thread.run(Thread.java:619)
              
              



              • 5. Re: Conversion errors writing h:selectBooleanCheckbox to boolean property within ui loop
                Nikos Paraskevopoulos Novice

                Hi again,


                Take a look at this:



                Caused by java.lang.IllegalArgumentException with message: "Cannot convert 0 of type class java.lang.Long to class java.lang.Boolean"

                org.jboss.el.lang.ELSupport.coerceToBoolean(ELSupport.java:177)
                [...]
                org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
                com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
                javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:390)
                [...]
                org.ajax4jsf.component.UIAjaxForm.processUpdates(UIAjaxForm.java:98)
                [...]




                The conversion error occurs when JSF is calculating the isRendered method of a component, the UIAjaxForm perhaps? Can you check the rendered attributes in your view? You could try removing all of them, then adding them one-by-one until you find the guilty.

                • 6. Re: Conversion errors writing h:selectBooleanCheckbox to boolean property within ui loop
                  Olly Edgell Newbie

                  Absolutely right. Another field on the form was checking the value of the checkbox in its render attribute. I'll be sure to avoid similar errors in the future!


                  Many thanks for taking the time to help.