13 Replies Latest reply on Mar 7, 2007 11:56 PM by mauhawk

    RichFaces with Ajax4Jsf

      I have the following jsp snippet:

      <rich:inputNumberSlider maxValue="1000000"
       minValue="100000" showBoundaryValues="true"
       value="#{bean.number}" id="number" inputSize="7">
       <aj4:support reRender="someOtherElement" event="onchange" />
      </rich:inputNumberSlider>
      ...
      ...
      <rich:panel id="someOtherElement">
      ...
      ...
      </rich:panel>
      


      Upon updating the slider, I get the following error:
      15:37:16,609 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet
       threw exception
      java.lang.NullPointerException
       at javax.faces.event.FacesEvent.queue(FacesEvent.java:57)
       at org.richfaces.renderkit.TabPanelRendererBase.doDecode(TabPanelRendere
      rBase.java:94)
       at org.ajax4jsf.framework.renderer.RendererBase.decode(RendererBase.java
      :76)
       at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:503
      )
       at javax.faces.component.UIInput.decode(UIInput.java:224)
       at org.richfaces.component.UISwitchablePanel.processDecodes(UISwitchable
      Panel.java:158)
       at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.
      java:605)
       at javax.faces.component.UIForm.processDecodes(UIForm.java:56)
       at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.
      java:605)
       at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:138)
       at org.ajax4jsf.framework.ajax.AjaxViewRoot.access$001(AjaxViewRoot.java
      :53)
       at org.ajax4jsf.framework.ajax.AjaxViewRoot$1.invokeRoot(AjaxViewRoot.ja
      va:254)
       at org.ajax4jsf.framework.ajax.JsfOneOneInvoker.invokeOnRegionOrRoot(Jsf
      OneOneInvoker.java:54)
       at org.ajax4jsf.framework.ajax.AjaxContext.invokeOnRegionOrRoot(AjaxCont
      ext.java:176)
       at org.ajax4jsf.framework.ajax.AjaxViewRoot.processDecodes(AjaxViewRoot.
      java:267)
       at org.apache.myfaces.lifecycle.ApplyRequestValuesExecutor.execute(Apply
      RequestValuesExecutor.java:32)
       at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl
      .java:95)
       at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java
      :70)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
      icationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
      ilterChain.java:173)
       at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(Extensions
      Filter.java:144)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
      icationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
      ilterChain.java:173)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseX
      MLFilter.java:96)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.
      java:220)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
      icationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
      ilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
      lter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
      icationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
      ilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
      alve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
      alve.java:178)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
      yAssociationValve.java:175)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
      torBase.java:432)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
      e.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
      ava:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
      ava:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
      ve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
      a:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
      :869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p
      rocessConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
      int.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWor
      kerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      


      Also, when i provide a value in the input field and press enter, I get forwarded to an error page with the same message.

      Regards,

        • 1. Re: RichFaces with Ajax4Jsf

          According to the stack trace, we miss the key player in your code snippet - the tabPanel. What the page structure you have and where is the form element located

          • 2. Re: RichFaces with Ajax4Jsf

            Here is the code snippet with form element and tab panels.

            
            <h:form id="form">
             <f:subview id="richTabbedPane">
             <f:verbatim>
             <center>
             </f:verbatim>
             <rich:spacer height="10" />
             <rich:tabPanel width="600px" switchType="client" id="tab_panel"
             height="200px">
             <rich:tab name="MyTab" label="MyTab">
             <h:panelGrid columns="2" cellpadding="2" cellspacing="0">
             <h:column>
             <h:outputText value="Number:" />
             </h:column>
             <h:column>
             <rich:inputNumberSlider maxValue="1000000"
             minValue="100000" showBoundaryValues="true"
             value="#{bean.number}" id="number" inputSize="7">
             <aj4:support reRender="someOtherElement" event="onchange" />
            </rich:inputNumberSlider>
             </h:column>
             </h:panelGrid>
             </rich:tab>
             </rich:tabPanel>
             <f:verbatim>
             </center>
             </f:verbatim>
             </f:subview>
             <f:subview id="richResultPane">
             <f:verbatim>
             <center>
             </f:verbatim>
             <rich:panel id="someOtherElement" style="width: 600px;">
             <f:facet name="header">
             <h:outputText value="Number" />
             </f:facet>
             <h:outputText value="#{bean.number}" />
             </rich:panel>
             <f:verbatim>
             </center>
             </f:verbatim>
             </f:subview>
            </h:form>
            
            


            Thanks,


            • 3. Re: RichFaces with Ajax4Jsf

              Wow. I see dozen problems why I might not work in your code.

              Why you use have so much subview? I did not understand the reason even for one of them

              h:column is for dataTable. You do not need it for panelGrid. Just drop them out.

              you can avoid this non-valid xml if you use style for centering and drop f:verbatim our. (Do you have something against facelets in your appl?)

              do no see the reason why to use the h:form around the whole content if you have only one input component

              • 4. Re: RichFaces with Ajax4Jsf

                I agree the code is not great; I am just a beginner with JSF and thought using RichFaces would ease development. I modified the code as per your suggestions: no more h:subview, h:column or f:verbatim. The problem still persists.

                I am using Ajax4Jsf 1.1.0 and MyFaces 1.1.5.

                Thanks.

                • 5. Re: RichFaces with Ajax4Jsf

                  ok. show what you have now.

                  • 6. Re: RichFaces with Ajax4Jsf

                    Here is the new jsp:

                     <f:view>
                     <rich:spacer height="10" />
                     <h:form id="form">
                     <rich:tabPanel width="600px" switchType="client" id="tab_panel"
                     height="200px">
                     <rich:tab name="MyTab" label="MyTab">
                     <h:panelGrid columns="1" cellpadding="2" cellspacing="0">
                     <rich:inputNumberSlider maxValue="1000000"
                     minValue="100000" showBoundaryValues="true"
                     value="#{bean.number}" id="number" inputSize="7">
                     <aj4:support reRender="someOtherElement" event="onchange" />
                     </rich:inputNumberSlider>
                     </h:panelGrid>
                     </rich:tab>
                     </rich:tabPanel>
                     </h:form>
                     <rich:panel id="someOtherElement" style="width: 600px;">
                     <f:facet name="header">
                     <h:outputText value="Number" />
                     </f:facet>
                     <h:outputText value="#{bean.number}" />
                     </rich:panel>
                     </f:view>
                    


                    • 7. Re: RichFaces with Ajax4Jsf

                      Ok. Please, replace it with the following and see what are the changes. If it does not work we have to dig into configuration stuff.

                      <f:view>
                      <rich:spacer height="10" />
                      <rich:tabPanel width="600px" switchType="client" id="tab_panel" height="200px">
                       <rich:tab name="MyTab" label="MyTab">
                       <h:form id="form">
                       <h:panelGrid columns="1" cellpadding="2" cellspacing="0">
                       <rich:inputNumberSlider maxValue="1000000" minValue="100000"
                       showBoundaryValues="true" value="#{bean.number}" id="number" inputSize="7">
                       <aj4:support reRender=":someOtherElement" event="onchange" />
                       </rich:inputNumberSlider>
                       </h:panelGrid>
                       </h:form>
                       </rich:tab>
                       </rich:tabPanel>
                       <rich:panel id="someOtherElement" style="width: 600px;">
                       <f:facet name="header">
                       <h:outputText value="Number" />
                       </f:facet>
                       <h:outputText value="#{bean.number}" />
                       </rich:panel>
                      </f:view>



                      • 8. Re: RichFaces with Ajax4Jsf

                        The only changes that I found were that the a4j:support's reRender attribute now refers to ":someOtherElement" rather than "someOtherElement" and the h:panelGrid component is enclosed by h:form. The application works this way.

                        However, if i have multiple tabs and the rich:tablePanel is enclosed by h:form, I get the same error that was mentioned before.

                         <f:view>
                         <rich:spacer height="10" />
                         <h:form id="form">
                         <rich:tabPanel width="600px" switchType="client" id="tab_panel"
                         height="200px">
                         <rich:tab name="Tab 1" label="Tab 1">
                         <h:panelGrid columns="1" cellpadding="2" cellspacing="0">
                         <rich:inputNumberSlider maxValue="1000000"
                         minValue="100000" showBoundaryValues="true"
                         value="#{bean.first}" id="number" inputSize="7">
                         <aj4:support reRender=":someOtherElement" event="onchange" />
                         </rich:inputNumberSlider>
                         </h:panelGrid>
                         </rich:tab>
                         <rich:tab name="Tab 2" label="Tab 2">
                         <h:panelGrid columns="1" cellpadding="2" cellspacing="0">
                         <rich:inputNumberSlider maxValue="1000000"
                         minValue="100000" showBoundaryValues="true"
                         value="#{bean.second}" id="number" inputSize="7">
                         <aj4:support reRender=":someOtherElement" event="onchange" />
                         </rich:inputNumberSlider>
                         </h:panelGrid>
                         </rich:tab>
                         </rich:tabPanel>
                         </h:form>
                         <rich:panel id="someOtherElement" style="width: 600px;">
                         <f:facet name="header">
                         <h:outputText value="Number" />
                         </f:facet>
                         <h:outputText value="#{bean.sum}" />
                         </rich:panel>
                         </f:view>
                        


                        • 9. Re: RichFaces with Ajax4Jsf

                          could you change switchType to "ajax" from "client" for the testing purpose, please

                          • 10. Re: RichFaces with Ajax4Jsf

                            Doing so eliminates the errors, but switching the tabs does not preserve the value selected by the rich:inputNumberSlider.

                            • 11. Re: RichFaces with Ajax4Jsf

                              what is a scope of your #{bean} ?

                              • 12. Re: RichFaces with Ajax4Jsf

                                the managed bean is in request scope.

                                • 13. Re: RichFaces with Ajax4Jsf

                                  Changing the scope of the managed bean to session works. However, there is a small delay for the slider to go back to its set position when switching tabs. Any idea as to why this should happen?

                                  This is the JSP:

                                   <f:view>
                                   <rich:spacer height="10" />
                                   <h:form id="form">
                                   <rich:tabPanel width="600px" switchType="ajax" id="tab_panel"
                                   height="200px">
                                   <rich:tab name="Tab 1" label="Tab 1">
                                   <h:panelGrid columns="1" cellpadding="2" cellspacing="0">
                                   <rich:inputNumberSlider maxValue="1000000"
                                   minValue="100000" showBoundaryValues="true"
                                   value="#{bean.first}" id="firstNumber" inputSize="7">
                                   <aj4:support reRender=":someOtherElement" event="onchange" />
                                   </rich:inputNumberSlider>
                                   </h:panelGrid>
                                   </rich:tab>
                                   <rich:tab name="Tab 2" label="Tab 2">
                                   <h:panelGrid columns="1" cellpadding="2" cellspacing="0">
                                   <rich:inputNumberSlider maxValue="1000000"
                                   minValue="100000" showBoundaryValues="true"
                                   value="#{bean.second}" id="secondNumber" inputSize="7">
                                   <aj4:support reRender=":someOtherElement" event="onchange" />
                                   </rich:inputNumberSlider>
                                   </h:panelGrid>
                                   </rich:tab>
                                   </rich:tabPanel>
                                   </h:form>
                                   <rich:panel id="someOtherElement" style="width: 600px;">
                                   <f:facet name="header">
                                   <h:outputText value="Number" />
                                   </f:facet>
                                   <h:outputText value="#{bean.sum}" />
                                   </rich:panel>
                                   </f:view>
                                  


                                  This is the relevant faces-config.xml

                                   <managed-bean>
                                   <managed-bean-name>bean</managed-bean-name>
                                   <managed-bean-class>
                                   sample.TestBean
                                   </managed-bean-class>
                                   <managed-bean-scope>session</managed-bean-scope>
                                   </managed-bean>