You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Ravindra Adireddy <ad...@gmail.com> on 2007/12/20 06:12:27 UTC
[Trinidad] How to delete a selected node from tr:tree
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
Re: [Trinidad] How to delete a selected node from tr:tree
Posted by Luka Surija <lu...@iytim.hr>.
And what is the procedure to select node of in tree trough managed bean,
without selectionListener, knowing only selected person from the list?
Matthias Wessendorf wrote:
> 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 <ad...@gmail.com> 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
>>
>
>
>
>
Re: [Trinidad] How to delete a selected node from tr:tree
Posted by Matthias Wessendorf <ma...@apache.org>.
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 <ad...@gmail.com> 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