fredsa / gwt-dnd

Library providing easy to use mouse or touch based drag-and-drop capabilities to GWT
43 stars 41 forks source link

Error in WidgetLocation #75

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What version of GWT are you using? 1.3.3? 1.4.60? Other?

1.6.4

What version of the gwt-dnd jar file or library file are you using?

2.6.2 and higher

What operating system(s) are you using? Windows? Linux? Mac?

Windows

Does the issue occur in web mode, hosted mode, both or don't know?

hosted mode and sometimes in web mode

What browser(s) do you use? Firefox, IE, Safari, other?

FF, IE

What is the browser version (if you know) from Help->About?

FF 3.0.x, IE 7

What steps will reproduce the problem? Please attach sample code if you
can.

1. Create a new GWT module
2. Instantiate WidgetLocation with any other widgets
3. Create a new HTML page that contains DIV with any ID
4. In GWT module add any widget using RootPanel.get(ID)

What is the expected output? What do you see instead?

Everything must works properly, but in hosted mode and sometimes in web
mode RootPanel throws an AssertException on the 4th step.

It occurs because it checks whether the getting element is a child of
another Root panel element. WidgetLocation sourec code has two lines that
look like:

widget == RootPanel.get()

It means that the parent element (BODY) is obtained before the child
element (DIV). Obviously they are nested and GWT invalidates the operation.

Do you have a workaround?

I tried to change order of steps 2,3 and 4 and it works for me, but I'm not
sure this workaround always solves the problem.

Please provide any additional information below.

I suggest replacing

widget == RootPanel.get() 

with

"body".equalsIgnoreCase(widget.getElement().getTagName())

It will always work properly.

Original issue reported on code.google.com by sskladch...@gmail.com on 23 Jun 2009 at 2:17

GoogleCodeExporter commented 9 years ago
Do you have a code snippet which illustrates the problem? In particular this 
step is not clear to me:
>   3. Create a new HTML page that contains DIV with any ID

Original comment by fredsa on 1 Jul 2009 at 4:31

GoogleCodeExporter commented 9 years ago
Ah, I see it was a wrong issue description.
See steps to reporduce the problem below:

1. Create a new GWT module
2. Create a new HTML page that contains DIV with any ID
3. Instantiate WidgetLocation with any other widgets
4. In GWT module add any widget using RootPanel.get(ID)

Actually an original code snipped is rather long but I'll try to explain what I 
mean.

Here is the HTML code:

<body>
<div id="myId"></div>
</body>

Here is GWT code:

WidgetLocation location = new WidgetLocation(widget, reference);
RootPanel.get("myId").add(new Label("My label")); // sometimes throws 
AsserException
in the RootPanel.detachOnWindowClose() method

Original comment by sskladch...@gmail.com on 1 Jul 2009 at 6:03

GoogleCodeExporter commented 9 years ago
I'm sorry. This is still a bit unclear to me. Do you have a EntryPoint class 
which 
demonstrates the problem?

Original comment by fredsa on 16 Oct 2009 at 7:52

GoogleCodeExporter commented 9 years ago

Original comment by fredsa on 31 Jan 2012 at 6:14