myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Renzo Tomaselli <>
Subject [Trinidad] about using disclosedRowKeys in tr:tree
Date Mon, 18 Feb 2008 18:26:24 GMT
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);
        component.setDisclosedRowKeys(set);      // ????
        treeModel.setRowIndex(0);         // force root level to be expanded
        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

View raw message