You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by venkata guddanti <ve...@gmail.com> on 2007/10/03 18:31:02 UTC

Re: [Trinidad] tree component - how to open a node programmatically on the Java side?

You can use the disclosedRowKeys attribute on the tree to pre-expand the
tree. You are using an array list as children of the tree nodes. These
arrayLists are automatically wrapped with a CollectionModel by Trinidad. The
Integer index of the row is the rowkey in each of the CollectionModel. The
rowKey for each node is a List containing these integers.

On 9/27/07, wolfgang.toepfer@pta.de <wo...@pta.de> wrote:
>
>
>
>
>
> Hi,
>
> Naively I followed the instructions on building a tree i.e. sth. like
>
> * Example: Given the following class:
> * <pre>
> * public class Person
> * {
> *    public Person(String name)
> *    {
> *      _name = name;
> *    }
> *
> *    public String getName()
> *    {
> *      return _name;
> *    }
> *
> *    public List getKids()
> *    {
> *      return _kids;
> *    }
> *
> *    private final String _name;
> *    private final List _kids = new ArrayList();
> * }
> * </pre>
> * You can construct a tree by:
> * <pre>
> * Person john = new Person("John Smith");
> * Person kim = new Person("Kim Smith");
> * Person tom = new Person("Tom Smith");
> * Person ira = new Person("Ira Wickrememsinghe");
> * Person mallika = new Person("Mallika Wickremesinghe");
> *
> * john.getKids().add(kim);
> * john.getKids().add(tom);
> * ira.getKids().add(mallika);
> *
> * // create the list of root nodes:
> * List people = new ArrayList();
> * people.add(john);
> * people.add(ira);
> * </pre>
> * Now you can construct a TreeModel by:
> * <pre>
> * TreeModel model = new ChildPropertyTreeModel(people, "kids");
>
>
> Now I would like to open a node programmatically on the Java side.
> However,
> when I use the isContainer method before enterContainer I get an
> IllegalArgument exception while trying to call
> javax.faces.model.ScalarDataModel.getRowData.
>
> Is there another way to open a certain node? Would I use rowKeys?
> Regarding the rowKey approach, I have the impression that the rowKey
> approach does not seem to be really feasible; as far as I can see in the
> debugger, I could only verify one rowKey instance for the root node but I
> did not find any other rowKey object for other existing nodes..
>
> Do I need to use the Menu variation of the tree classes for rowKeys to
> work?
>
> Further details:
> I use a Pojo MenuItem that has a children property which is an
> ArrayList<MenuItem>.
> I use SEAM 2.0 RC1.
> I apply the org.apache.myfaces.trinidad.model.ChildPropertyTreeModel
> implementation of org.apache.myfaces.trinidad.model.TreeModel.
>
> Many thanks,Wolfgang.
>
> PTA Programmier-Technische Arbeiten GmbH
> Seckenheimer Str. 65-67, 68165 Mannheim
> Amtsgericht Mannheim, HRB 1139
> USt-IdNr.: DE 143 839 368
> Geschäftsführer:
> Dipl.-Ing. Peter Fischer
> Dr. Harald W. Busch
> Dipl.-Kfm. Knut Fischer
>
> **********************************************************************
> http://www.pta.de
> Mit 1501 Erfahrungsberichten aus 38 Jahren erfolgreicher Projektarbeit!
> **********************************************************************