2 Replies Latest reply on Sep 16, 2011 12:28 PM by jsoye

    rich:tree and JSF lifecycle

    jsoye Newbie

      Hi all,

      I'm having a problem refreshing a display which uses a rich:tree for navigation and

      a dynamically generated HtmlPanelGrid (depending on the tree node selected). It always

      displays the previous result (as opposed to the last one selected). I've tried using

      immediate="true" but the same behaviour results.

       

      My code is

      {code}

              <rich:tree id="myTree" var="node" nodeType="#{node.type}" value="#{myBean.treeNodes}"

                         toggleType="client" selectionType="ajax" immediate="true">

                  <rich:treeNode type="CATEGORY_1" iconExpanded="...png" iconCollapsed="...png">

                      <a4j:outputPanel>

                          <h:outputText value="#{node}" />

                          <a4j:ajax render="gridPanel" event="click"  immediate="true" listener="#{myBean.updateSelectedNode(node)}"/>

                      </a4j:outputPanel>               

                  </rich:treeNode>

                  <rich:treeNode type="CATEGORY_2" iconExpanded="...png" iconCollapsed="...png">

                      <h:outputText value="#{node}" />

                  </rich:treeNode>

              </rich:tree>

                     

              ...       

             

              <h:panelGroup id="gridPanel" layout="block">

                  <h:panelGrid id="displayGrid" binding="#{dynamicComponentBean.displayGrid}" columns="2" />

              </h:panelGroup>      

      {code}

       

      I also used a different selection listener style, i.e.

       

      {code}

                  <rich:treeSelectionChangeListener for="myTree" listener="#{myBean.nodeTreeSelectionChanged}"/>

      {code}

                 

      but the same problem occurs - I can't get the panelGroup to refresh immediately with the panelGrid corresponding to the node selected.

       

      If anyone could shed some light I'd be very grateful. Thanks.

        • 1. Re: rich:tree and JSF lifecycle
          jsoye Newbie

          Sorry,

          I should have added that I'm using

           

          • Richfaces 4.1.0.20110805-M1
          • JBoss AS 7 Final
          • Seam 3.0.0.Final
          • 2. Re: rich:tree and JSF lifecycle
            jsoye Newbie

            Gotcha. Took a break for a few days and moved onto something else. Returned afresh (not really!) and tried a slight variation. Works this way.

            Here's my approach for those interested. Might save you from the headaches it caused me.

             

             

                    <rich:tree id="myTree" var="node" nodeType="#{node.type}" value="#{myBean.treeNodes}"

                               toggleType="client" selectionType="ajax">

                        <rich:treeSelectionChangeListener for="myTree" listener="{myBean.nodeTreeSelectionChanged}"/>

                        <rich:treeNode type="CATEGORY_1" iconExpanded="...png" iconCollapsed="...png">

                            <a4j:outputPanel>

                                <h:outputText value="#{node}" />

                                <a4j:ajax event="click" render="gridPanel"/>

                            </a4j:outputPanel>

                        </rich:treeNode>

                        <rich:treeNode type="CATEGORY_2" iconExpanded="...png" iconCollapsed="...png">

                            <a4j:outputPanel>

                                <h:outputText value="#{node}" />

                                <a4j:ajax event="click" render="gridPanel"/>

                            </a4j:outputPanel>

                        </rich:treeNode>

                    </rich:tree>

             

            I thought I had tried this approach before, but obviously I missed something. C'est la vie.