You can construct a tree by:
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);
Now you can construct a TreeModel by:
TreeModel model = new ChildPropertyTreeModel(people, "kids");
the constructor calls:
-setWrappedData(...); (with people)
-setChildProperty(...); (with "kids")
setWrappedData() is overridden from javax.faces.model.DataModel;
with getWrappedData(); you get acces to the List of people.
So... what you want it to "update" the used model;
(remove/add objects from/to the list)
and you can use these methods to sync the data, represented by the
(childproperty)treemodel.
HTH,
M
On Dec 20, 2007 6:12 AM, Ravindra Adireddy <[EMAIL PROTECTED]> wrote:
> Hi all
>
>
>
> I am creating a trinidad tree from ArrayList using
>
> _model = new ChildPropertyTreeModel(getPeople(), "kids");
>
> When the tree is created i want to add some parent nodes and child nodes and
> i have to provide on option to delete selected nodes. Please help me.
>
> Please post some code examples if posible.......Is there any API support to
> achieve this or i need to code my self. If there is no API support please
> guide me how can i write my own code to achieve this.
>
>
> --
> Thanks and Regards
> Ravindra Adireddy
--
Matthias Wessendorf
further stuff:
blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
mail: matzew-at-apache-dot-org