two trees on one page.

4 views
Skip to first unread message

Jill Singer

unread,
Jan 13, 2009, 12:06:21 PM1/13/09
to Google Web Toolkit
when I have two trees on one page-

even if they are in different "verticalpanels" (which I know are just
columns in a table),
when I select an item on the first; the second tree disappears.

this behavior occurs in hosted mode and in ie, but not in firefox (and
I need to make it work in ie; and hosted mode would be helpful)

any ideas?

(if I redraw one right after adding a new item to the other tree; then
it will show up; but the selection problem is annoying...I don't want
to be continually redrawing if I can help it)

is this a css problem?

please note: I'm using gwt 1.462 (and no, I cannot upgrade; that it
the version my company is using now)

here's some sample code that can be run to demonstrate the problem
(just instantiate it and put it in an entry-point class):
package com.amicas.gwt.qc.client.widgets.dragndrop;

import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Tree;
import com.google.gwt.user.client.ui.TreeItem;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

public class DualTreeTest extends AbsolutePanel {

//
STATIC //////////////////////////////////////////////////////////////////
/** shorthand to refer to the left box */
private static final int LEFT =0;
/** shorthand to refer to the right box */
private static final int RIGHT =1;

//
STATE //////////////////////////////////////////////////////////////////
private VerticalPanel its_leftBox;
private VerticalPanel its_rightBox;


public DualTreeTest() {

HorizontalPanel hpan = new HorizontalPanel();
//hpan.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

its_leftBox = new VerticalPanel();

its_leftBox.add(makeTree());
its_leftBox.add(new HTML("<P>"));
//its_leftBox.addMouseListener(new TreeMouseAdapter());
hpan.add(its_leftBox);

its_rightBox = new VerticalPanel();
its_rightBox.add(makeTree());
hpan.add(its_rightBox);

add(hpan);
}


public Tree makeTree(){
Tree leftTree = new Tree();
TreeItem level1 = new TreeItem("level1-1");
TreeItem leafa = new TreeItem("a");
TreeItem leafb = new TreeItem("b");
TreeItem leafc = new TreeItem("c");
TreeItem leafd = new TreeItem("d");

level1.addItem(leafa);
level1.addItem(leafb);
level1.addItem(leafc);
level1.addItem(leafd);

TreeItem level2 = new TreeItem("level1-2");
TreeItem leafa2 = new TreeItem("a2");
TreeItem leafb2 = new TreeItem("b3");
TreeItem leafc2 = new TreeItem("c4");
TreeItem leafd2 = new TreeItem("d5");

level2.addItem(leafa2);
level2.addItem(leafb2);
level2.addItem(leafc2);
level2.addItem(leafd2);

leftTree.addItem(leve11);
leftTree.addItem(leve12);

return leftTree;
}
}


Jill Singer

unread,
Jan 15, 2009, 5:26:46 PM1/15/09
to Google Web Toolkit
I solved the problem:

I searched through the net, and found this post:
http://markmail.org/message/zozobs24v4wyvf6p

and wondered if that quirk was causing my problem.

I already was using a subclass of Tree,
so added to the constructor:


DOM.setStyleAttribute(getElement(), "position", "static");

and; now the second tree is not disappearing when I select the first
tree.
I'm planning to file a bug on this issue.
Reply all
Reply to author
Forward
0 new messages