You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Anup Gokhale <an...@gmail.com> on 2015/09/25 13:41:52 UTC

Wicket Tree - Getting The Selected Node

Hi.

 

Am a complete noob to Wicket and am currently learning Wicket by writing
small example applications. Have worked my way through all the basic
components like TextField, Links, Labels, Buttons, ListView, DataTable etc.
Have now reached DefaultNestedTree and it's many avatars. Am totally stuck
in fetching the currently selected nodes. How do our models know which
node(s) the user has currently selected in the tree? Also are there any
events that get fired when the user clicks on a tree node?

 

This is my very first post to the wicket user group, and I must say that
Wicket developers and committers have done a commendable job. Thanks for
developing such a wonderful framework.

 

Warm regards,

 

Anup Gokhale

 



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

Re: Wicket Tree - Getting The Selected Node

Posted by Anup <an...@gmail.com>.
Thanks Sven. Things are clear to me now.

Regards,

Anup

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Tree-Getting-The-Selected-Node-tp4672040p4672044.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket Tree - Getting The Selected Node

Posted by Sven Meier <sv...@meiers.net>.
Hi,

     @Override
     public Component newContentComponent(String id, IModel<Foo> model)
     {
         return new Folder<Foo>(id, this, model)
         {
             /**
              * Always clickable.
              */
             @Override
             protected boolean isClickable()
             {
                 return true;
             }

             @Override
             protected void onClick(AjaxRequestTarget target)
             {
                 Employee employee = getModelObject();
                 // keep selection somewhere, exchange components or 
switch to other page
             }

             @Override
             protected boolean isSelected()
             {
                 // get selected status somewhere
                 return false;
             }
         };
     }

Have fun
Sven


On 25.09.2015 14:12, Anup wrote:
> Sven Meier wrote
>> a NestedTree does not have any notion of 'selection'.
>> But the set of expanded nodes is kept in the tree's model object, see
>> AbstractTree#expand() and #collapse().
>>
>> You decide how to represent each node's content, for this you'll have to
>> override AbstractTree#newContentComponent(). The default will just
>> expand and collapse the tree branches on each click, see
>>
>> org.apache.wicket.extensions.markup.html.repeater.tree.content.Folder
>>
>> You can override Folder's methods or use any other component to
>> represent your nodes.
> Thanks Sven. I have understood the above as I can see the expanded nodes by
> inspecting tree.getModel(). What still foxes me is how do I take some
> action, when the user clicks a particular node? For example if each node is
> representing an employee, then how can I display the details of the desired
> employee when the user clicks/selects on the corresponding employee node?
>
> Regards,
> Anup
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Tree-Getting-The-Selected-Node-tp4672040p4672042.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket Tree - Getting The Selected Node

Posted by Anup <an...@gmail.com>.
Sven Meier wrote
> a NestedTree does not have any notion of 'selection'.
> But the set of expanded nodes is kept in the tree's model object, see 
> AbstractTree#expand() and #collapse().
> 
> You decide how to represent each node's content, for this you'll have to 
> override AbstractTree#newContentComponent(). The default will just 
> expand and collapse the tree branches on each click, see
> 
> org.apache.wicket.extensions.markup.html.repeater.tree.content.Folder
> 
> You can override Folder's methods or use any other component to 
> represent your nodes.

Thanks Sven. I have understood the above as I can see the expanded nodes by
inspecting tree.getModel(). What still foxes me is how do I take some
action, when the user clicks a particular node? For example if each node is
representing an employee, then how can I display the details of the desired
employee when the user clicks/selects on the corresponding employee node?

Regards,
Anup

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Tree-Getting-The-Selected-Node-tp4672040p4672042.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket Tree - Getting The Selected Node

Posted by Sven Meier <sv...@meiers.net>.
Hi,

a NestedTree does not have any notion of 'selection'.
But the set of expanded nodes is kept in the tree's model object, see 
AbstractTree#expand() and #collapse().

You decide how to represent each node's content, for this you'll have to 
override AbstractTree#newContentComponent(). The default will just 
expand and collapse the tree branches on each click, see

org.apache.wicket.extensions.markup.html.repeater.tree.content.Folder

You can override Folder's methods or use any other component to 
represent your nodes.

Have fun
Sven


On 25.09.2015 13:41, Anup Gokhale wrote:
> Hi.
>
>   
>
> Am a complete noob to Wicket and am currently learning Wicket by writing
> small example applications. Have worked my way through all the basic
> components like TextField, Links, Labels, Buttons, ListView, DataTable etc.
> Have now reached DefaultNestedTree and it's many avatars. Am totally stuck
> in fetching the currently selected nodes. How do our models know which
> node(s) the user has currently selected in the tree? Also are there any
> events that get fired when the user clicks on a tree node?
>
>   
>
> This is my very first post to the wicket user group, and I must say that
> Wicket developers and committers have done a commendable job. Thanks for
> developing such a wonderful framework.
>
>   
>
> Warm regards,
>
>   
>
> Anup Gokhale
>
>   
>
>
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org