Problem with tree:nodeSelectListener
bolsover Sep 30, 2009 5:40 AMI'm having a problem setting a NodeSelectListener on a dynamically built HtmlTree.
Heres my code:
JSF:
<rich:panel style="width: 900px"> <h:form> <h:panelGrid columns="5"> <rich:tree binding="#{NavigationListBean.tree1}" ></rich:tree> <%-- other trees --%> </h:panelGrid> </h:form> </rich:panel>
JAVA:
public HtmlTree getTree1() { return buildTree(1); } private HtmlTree buildTree(int menuNo) { HtmlTree tree = new HtmlTree(); NavigationDao dao = new NavigationDao(); Navigation top = dao.retrieveActiveTopLevelNavigationsBySeq(menuNo); TreeNodeImpl rootNode = new TreeNodeImpl(); tree.setAjaxKeys(null); tree.setAjaxSubmitSelection(true); tree.setSwitchType("client"); tree.setPreserveModel("true"); tree.setStyle("width:150px"); MethodBinding binding = AppUtils.getCurrentApplication().createMethodBinding("#{NavigationListBean.processSelection}", new Class[] { NodeSelectedEvent.class }); tree.setNodeSelectListener(binding); rootNode.setData(top.getSeq()); TreeNodeImpl childNode = new TreeNodeImpl(); childNode.setData(top.getMenu()); rootNode.addChild(top, childNode); List<Navigation> treeNavigations = dao.retrieveActiveNavigationsByParentMenu(top.getMenu()); walkTree(childNode, treeNavigations); tree.setValue(rootNode); return tree; } private void walkTree(TreeNode parentNode, List<Navigation> treeNavigations) { NavigationDao dao = new NavigationDao(); TreeNodeImpl childNode; for (Navigation nav : treeNavigations) { childNode = new TreeNodeImpl(); childNode.setData(nav.getMenu()); parentNode.addChild(nav, childNode); List<Navigation> childNavigations = dao.retrieveActiveNavigationsByParentMenu(nav.getMenu()); walkTree(childNode, childNavigations); } } public void processSelection(NodeSelectedEvent event) { // this method never called HtmlTree tree = (HtmlTree) event.getComponent(); Navigation selectedNavigation = (Navigation) tree.getRowData(); System.out.println(selectedNavigation.toString()); }
The trees are displayed on page just fine - but the processSelection(NodeSelectedEvent) is never called -- any help please?