two tree problems
coralfe Jul 24, 2008 12:16 PMI am using richfaces with seam.
The tree is mostly working, but I am experiencing two problems.
1) The first is that the tree's nodeSelectListener mostly works, but every now and then the event just does not get fired and the page needs to be reloaded before it will work again. There are no obvious exceptions being thrown.
2) The second problem involves programatically expanding the tree.
I am binding the tree to a seam component and trying to keep the tree expanded in sync with a <a4j:commandLink/> on a separate part of the page, but when the commandLink is called the tree's rowKey is null and calling tree.queueNodeExpand(new ListRowKey(arrayList)); throws an illegalStateException "No tree element available or row key not set".
As an aside rowKey send in the nodeselectionListener event's tree is not null.
I have tried changing the scope of the binding to no avail.
How can I expand the tree from a link outside of the tree?
The same code breaks trying to get the tree expanding only the first level while populating the initial TreeNode's.
Parts of Relevant code follows:
page:
<rich:tree style="width:180px;overflow: scroll;overflow-y:hidden" nodeSelectListener="#{conceptViewBacking.processSelection}" ajaxSubmitSelection="true" switchType="ajax" rendered="#{strategyMapPanelBacking.showConceptViewComponents}" value="#{conceptViewBacking.treeHolder}" var="item" nodeFace="#{item.type}" reRender="conceptForm" binding="#{treeBinding.tree}" ajaxSingle="true" id="conceptTree" > <rich:treeNode type="strategy" iconLeaf="../img/conceptview/strategy.png" icon="../img/conceptview/strategy.png" reRender="conceptDetail" id="strategyTreeNode"> <h:outputText value="#{item.name}" /> </rich:treeNode> <rich:treeNode type="vertical" iconLeaf="../img/conceptview/vertical.gif" icon="../img/conceptview/vertical.gif" id="verticalTreeNode"> <h:outputText value="#{item.name}" reRender="conceptDetail"/> </rich:treeNode> </rich:tree>
commandLinkAction:
@In(create = true) TreeBinding treeBinding; public void expandTreeAboveStrategy(StrategyBubble sBubble) { ArrayList<Long> arrayList = new ArrayList<Long>(); ///... code to collecting rowKeys try { HtmlTree tree = getTreeBinding().getTree(); final Object rowKey = tree.getRowKey();//null tree.queueNodeExpand(new ListRowKey(arrayList));//error } catch (IOException e) { FacesUtil.sendInfoMsg("problem expanding tree"); e.printStackTrace(); } }
binding:
@Name("treeBinding") @Scope(ScopeType.EVENT) public class TreeBinding { private HtmlTree tree; public HtmlTree getTree() { return tree; } public void setTree(HtmlTree tree) { this.tree = tree; } }