1 Reply Latest reply on Nov 10, 2009 4:59 AM by Nick Belaevski

    Rich tree reRender issue.

    Robert Jones Newbie

      Hi,

      I am using a rich tree to display steps in a workflow. When a node in the tree is selected it triggers a call to the nodeSelectListener method.

      In that method, if the selected step is valid, then that node should be displayed with a yellow background (highlighted). Furthermore, the previously selected step (if there was one) must be unset (un-highlighted).

      While the selected step is correctly displaying as highlighted, the previously selected step is not being un-highlighted. As a result it appears as though multiple steps are selected. If I move off the page and come back to it, the tree displays correctly.

      Is the solution to force the tree to reRender itself? If so, how can I accomplish that? If not, what can be done?

      Here is my jsp code:

      <rich:tree id="workflowTree" style="width:300px" value="#{workflowController.workflowRoot}"
       var="step" nodeFace="#{step.type}"
       ajaxSubmitSelection="true"
       switchType="client"
       componentState="#{workflowController.workflowTreeState}"
       nodeSelectListener="#{workflowController.onWorkflowStepTreeNodeSelected}">
       <rich:treeNode type="workflow" id="workflowStep"
       iconLeaf="/resources/images/set-leader.gif" icon="/resources/images/set-leader.gif">
       <h:outputText style="#{step.styleClass}" value="#{step.objWkflwStep.wkflwStepNam}" />
       </rich:treeNode>
       <rich:treeNode type="adhoc_workflow" id="adhocStep"
       iconLeaf="/resources/images/set-member.gif" icon="/resources/images/set-member.gif">
       <h:outputText style="#{step.styleClass}" value="#{step.objWkflwStep.wkflwStepNam}" />
       </rich:treeNode>
       </rich:tree>
      


      And here is the nodeSelectListener method:
       /**
       * Method called when a node is selected from the workflow step tree
       */
       public void onWorkflowStepTreeNodeSelected (NodeSelectedEvent event) {
       HtmlTree tree = (HtmlTree) event.getSource();
       WorkflowTreeNode newlySelectedNode = (WorkflowTreeNode) tree.getRowData();
       Workflow workflow = (Workflow)getObjectInfoBean().getObjectBean();
      
       //Check if newly selected node is a valid next step
       if (isValidNextWorkflowStep(newlySelectedNode)) {
       if (workflow.getSelectedRowKey() != null) {
       // assign normal style class to selected node if applicable
       WorkflowTreeNode selectedNode = (WorkflowTreeNode) tree.getRowData(workflow.getSelectedRowKey());
       selectedNode.setStyleClass(null);
       }
      
       // assign newly selected node as selected workflow node
       newlySelectedNode.setStyleClass("background-color:yellow");
       workflow.setSelectedWkflwNode(newlySelectedNode);
       workflow.setSelectedRowKey(workflowTreeState.getSelectedNode());
       }
       }
      


      Also, and this is a slightly different topic, when the switchType is set to 'ajax' the nodeSelectListener is not being called for 2nd level nodes. Any thoughts on why that might be?

      Thanks in advance for your time and assistance.

      Rob

        • 1. Re: Rich tree reRender issue.
          Nick Belaevski Master

          Hi Rob,

          While the selected step is correctly displaying as highlighted, the previously selected step is not being un-highlighted. As a result it appears as though multiple steps are selected. If I move off the page and come back to it, the tree displays correctly.

          Use "ajaxNodeKeys" or "ajaxKeys" attributes to point to keys of nodes you need to update.

          Also, and this is a slightly different topic, when the switchType is set to 'ajax' the nodeSelectListener is not being called for 2nd level nodes. Any thoughts on why that might be?

          This can be caused by unsynchronization of model and component state. When subsequent (after initial rendering) request from component is processed, all model nodes that were output to the client previously are processed. If there are no such nodes in model at this step, then tree component just won't handle them. Are expands or nested commmand/input components handled ok for the 2nd level nodes and below in ajax mode?