File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes GWT and the fly likes Expand and Fold GWT Tree Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » GWT
Bookmark "Expand and Fold GWT Tree" Watch "Expand and Fold GWT Tree" New topic
Author

Expand and Fold GWT Tree

Sergey Kargopolov
Ranch Hand

Joined: Jul 04, 2003
Posts: 63
Hi!

I am having difficulty with Expanding and Folding the GWT Tree.

When user selects TreeItem with a mouse click I want the Tree to expand. And when user clicks on TreeItem again I want the Tree to Fold. The problem is that if I click on TreeItem when Tree is unfolded it Folds, and then immediately unfolds again. Looks like SelectionEvent is triggered twice . Here is my code:


public void onSelection(SelectionEvent<TreeItem> event) {
TreeItem t = event.getSelectedItem();
boolean isOpen = t.getState();

if(isOpen)
{
t.setState(false);

} else {
t.setState(true);
}
});

Please advise me...

Thank you.
Rakesh Chaudhary
Ranch Hand

Joined: Feb 19, 2008
Posts: 120
Hi,

Try this

webpage

BOB..



Acquire the unexpected.......
Preparing for SCJP 6
Sergey Kargopolov
Ranch Hand

Joined: Jul 04, 2003
Posts: 63
Rakesh, thank you very much for your post.

I am sorry, may be I did not describe my problem clear enough but I cannot find an example that folds and unfolds GWT Tree by selecting or clicking on Tree Item. I cannot find SelectionEvent example. Clicking on "+" is not what I am interested in. I need Tree to unfold and fold when users clicks on TreeItem. Code that I posted above does not work as I expect it to work. An event is triggered twice.

Thank you.
dayananda veerappa
Greenhorn

Joined: Apr 02, 2012
Posts: 2
any help on this, why an event is triggered twice onselection method
Daniel Renner
Greenhorn

Joined: Mar 29, 2012
Posts: 10
Look after the content of the event. Maybe the click event also triggers the select event (2 calls, select + click). I develop only in gxt, with a different event handling, but there more than 1 way to catch events. Is there something similar to addListener(Events.OnSelect, new ..listener()); in GWT?
dayananda veerappa
Greenhorn

Joined: Apr 02, 2012
Posts: 2
thank you so much for replay, tree don't have addListener(Events.OnSelect, new ..listener()); method,
can you post sample code for gxt. thanks inadvance
Daniel Renner
Greenhorn

Joined: Mar 29, 2012
Posts: 10
Nah, you dont need the gxt code. It doesnt help you.
So can you please post the code where you define the listener for the tree (method)? Which gwt version do you use?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Expand and Fold GWT Tree
 
Similar Threads
Context Menu on Tree in GWT 2.0.3
How to expand tree in gwt?
Slider usage with a Tree
Sample code to drag drop buttons in Applet
Adding anchor tag to URL