nodeSelectListener
bolsover Jun 2, 2009 7:27 AMI'm having a real problem getting a nodeSelectListener to work... it just will not respond ehere is the page code:
<h:panelGrid columns="2" width="100%"> <rich:tree style="width:300px" switchType="client" value="#{BillExplosionBean.rootNode}" var="item" ajaxKeys="#{null}"> <rich:treeNode nodeSelectListener="#{BillExplosionBean.processSelection}" reRender="selectedNode" ajaxSubmitSelection="true" > <h:outputText value="#{item.seq}" /> <h:outputText value=": " /> <h:outputText value="#{item.part}" /> <h:outputText value=": " /> <h:outputText value="#{item.usage}" /> </rich:treeNode> </rich:tree> <h:outputText escape="false" value="Selected Node: #{BillExplosionBean.nodeTitle}" id="selectedNode" /> </h:panelGrid>
Here is the bean code
public void retrieveBill(String parent){ rootNode = new TreeNodeImpl(); Bill bill = new Bill(); bill.setPart(parent); TreeNode parentNode = new TreeNodeImpl(); parentNode.setData(bill); rootNode.addChild(bill, parentNode); List<Bill> bills = dao.retrieveBillByParent(parent); walkTree(parentNode, bills); FacesContext fc = FacesContext.getCurrentInstance(); ExternalContext ec = fc.getExternalContext(); HttpServletRequest httpReq = (HttpServletRequest) ec.getRequest(); httpReq.setAttribute(AppConstants.BILL_EXPLOSION_BEAN, this); } private void walkTree(TreeNode parent, List<Bill> bills){ for (Bill bill : bills){ // do some processing to build the tree TreeNodeImpl nodeImpl = new TreeNodeImpl(); nodeImpl.setData(bill); parent.addChild(bill, nodeImpl); // uncomment to output to System.out // get the subordinate parts List<Bill> childBills = dao.retrieveBillByParent(bill.getPart()); walkTree(nodeImpl, childBills); } } public void processSelection(NodeSelectedEvent event) { HtmlTree tree = (HtmlTree) event.getComponent(); nodeTitle = (String) tree.getRowData(); selectedNodeChildren.clear(); TreeNode currentNode = tree.getModelTreeNode(tree.getRowKey()); if (currentNode.isLeaf()){ selectedNodeChildren.add((String)currentNode.getData()); }else { Iterator<Map.Entry<Object, TreeNode>> it = currentNode.getChildren(); while (it!=null &&it.hasNext()) { Map.Entry<Object, TreeNode> entry = it.next(); selectedNodeChildren.add(entry.getValue().getData().toString()); } } }
The tree displays nicely on the page and will expand/collapse but selecting a node does not call the processSelection(NodeSelectedEvent event) method and I am at a loss as to why.
Anyone?