7 Replies Latest reply on Jul 4, 2011 10:30 AM by raissi

    RF_4.1.0: action and actionListener of <h:commandLink> inside <rich:treeNode>

    pablo53

      Hi!

       

      I have the following piece of code:

       

      <rich:tree id="treeValidations" rendered="#{myBean.showTree}"

                 value="#{myBean.myNodes}" var="mynode"

                 nodeType="#{mynode.type}" toggleType="client">

          <rich:treeNode type="my.type"

                         iconLeaf="#{resource['images:th_validation.gif']}"

                         iconCollapsed="#{resource['images:th_validation.gif']}"

                         iconExpanded="#{resource['images:th_validation.gif']}">

              <h:commandLink action="#{myBean.doAction}" actionListener="#{myBean.listenAction}">

                click me

              </h:commandLink>

           </rich:treeNode>

           <!-- an so on... -->

      </rich:tree>

       

       

      When I click the link inside the node no action is performed (I mean myBean.doAction and myBean.listenAction are not called). When I mode <h:commandLink> outside the tree everythong seems to work - both methods defined inside the tag are executed.

       

      What am I doing wrong? I would like to undertake some action when user clicks a node. How to do that?

       

       

      Regards,

      Paweł

        • 1. Re: RF_4.1.0: action and actionListener of <h:commandLink> inside <rich:treeNode>
          sarocks

          Hi,

           

          You can use a4j:commandLink instead of h:commandLink.

          It works fine for me!

           

                    <h:form>
                      <rich:tree id="tree" nodeType="#{node.type}" var="node"
                          value="#{treeBean.rootNodes}" toggleType="client">
                          
                         <rich:treeNode type="country">
                              <a4j:outputPanel layout="block">
                                  <a4j:commandLink value="#{node.name}"
                                      action="#{treeBean.actionEvent}"
                                      actionListener="#{treeBean.actionListenerEvent}">
                                  </a4j:commandLink>
                              </a4j:outputPanel>
                          </rich:treeNode>
                          
                      </rich:tree>
                  </h:form>
          

           

           

          Thanks.

          • 2. Re: RF_4.1.0: action and actionListener of <h:commandLink> inside <rich:treeNode>
            raissi

            Hello Saroj,

            I am using the same code that you've posted. I obtained the following exception:

             

            Jun 30, 2011 3:10:47 PM org.richfaces.context.ExtendedPartialViewContextImpl processPartialExecutePhase

            SEVERE: java.lang.NullPointerException

            javax.faces.FacesException: java.lang.NullPointerException

                    at org.richfaces.component.UIDataAdaptor.invokeOnComponent(UIDataAdaptor.java:1124)

                    at org.richfaces.renderkit.TreeRendererBase.decode(TreeRendererBase.java:208)

                    at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:787)

                    at org.richfaces.component.UIDataAdaptor.processDecodes(UIDataAdaptor.java:824)

                    at javax.faces.component.UIForm.processDecodes(UIForm.java:225)

                    at org.richfaces.context.PartialViewExecuteVisitCallback.visit(PartialViewExecuteVisitCallback.java:55)

                    at org.richfaces.context.BaseExtendedVisitContext.invokeVisitCallback(BaseExtendedVisitContext.java:337)

                    at javax.faces.component.UIForm.visitTree(UIForm.java:354)

                    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)

             

            Can you help me with this, please .

            Thanks.

            • 3. Re: RF_4.1.0: action and actionListener of <h:commandLink> inside <rich:treeNode>
              sarocks

              Could you upgrade the JSF libraries to latest release!

              I am not sure but it may help.

               

              See the link below, end of the page:

              http://javaserverfaces.java.net/nonav/rlnotes/2.1.2/migration.html

               

              Disable partial state saving for the application by specifying a context initialization parameter called javax.faces.PARTIAL_STATE_SAVING with a value of false.

              • 4. Re: RF_4.1.0: action and actionListener of <h:commandLink> inside <rich:treeNode>
                raissi

                Hello again,

                Thanks for the response,

                It's so weird. In fact, when I ommit the a4j:commandLink, the tree works fine.

                I tried your solution (disable state saving), but nothing happened.

                • 5. Re: RF_4.1.0: action and actionListener of <h:commandLink> inside <rich:treeNode>
                  sarocks

                  Ok. I am not sure why this problem!

                  Once I got this exception, then I upgraded jsf to 2.1.1 and made the changes in web.xml. Then i never had this issue.

                  I am using tomcat 6.0.20 and Richfaces 4.0.0.Final

                   

                  If the code I posted only giving this problem then its weired, because it works for me.

                   

                  Or else you could do a little googling, may be something else causing this problem, i found something like below:

                  http://stackoverflow.com/questions/6207800/richtree-nullpointerexception-on-node-click

                  • 6. Re: RF_4.1.0: action and actionListener of <h:commandLink> inside <rich:treeNode>
                    pablo53

                    There MUST be an error in RF 4.1.0

                     

                    The same problem concerns <h:commandLink> inside a <h:dataTable> which is placed inside a <rich:tabPanel>. If I put it outside <rich:tabPanel> it works, when I put it inside <rich:tabPanel> - it does not.

                     

                     

                    Regards,

                    • 7. Re: RF_4.1.0: action and actionListener of <h:commandLink> inside <rich:treeNode>
                      raissi

                      Hi Paweł,

                      Did you specify the value of the "name" attribute inside commandLink ? If not, can you try it ? I had the same issue as yours, but with RF 3.3, When I ommit the name attribute, then, nothing happens when clicking on the link.

                      I hope this helps,

                      Best Regards,