You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Renzo Tomaselli <re...@tecnotp.it> on 2008/02/18 19:26:24 UTC
[Trinidad] about using disclosedRowKeys in tr:tree
Hi - as a fairly common situation - I need to expand the first level of
a tree.
I adopted a pattern which works since a long time. However I wonder
about any chance to keep it simpler, since I miss some logics in it.
The working pattern is:
<tr:tree binding="#{bean.component}" disclosedRowKeys="#{bean.disclosed}"...
and in the bean:
public CoreTree getComponent() { return component; }
public void setComponent(CoreTree c) { component = c; }
public RowKeySet getDisclosed() {
RowKeySet set = new RowKeySetTreeImpl(false);
set.setCollectionModel(treeModel);
component.setDisclosedRowKeys(set); // ????
treeModel.setRowIndex(0); // force root level to be expanded
set.add(treeModel.getRowKey());
return set;
}
Now I wonder why I have - at the same time - to return a key set AND to
give it to the tree component. If I comment out
"component.setDisclosedRowKeys(set)" then I get a class cast exception
in PPR while trying to expand the root node, and no effect while
expanding any other node.
I expected that returning a proper key set should be all is needed to
implement the disclosedRowKeys attribute.
Moreover - since the component keeps track of user-initiated expansions
- I guess there is another set somewhere, but if I call on
component.getDisclosedRowKeys() then I'm back on my own getDisclosed
method (and yes, an infinite loop).
My target is to avoid catching components as much as I can - since they
are a common source of troubles with Facelets (get/set are called at
compile time, no way with iterating components, etc.).
Any help is welcome, thanks.
-- Renzo