Rich tree reRender issue.
rhpjones Nov 9, 2009 8:47 PMHi,
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