Closed GoogleCodeExporter closed 9 years ago
it seems the second line is wrong, you have to pass a widget instead of
$(widget) which returns a GQuery.
2. jsPane.add(myWidget);
I think it's a mistake when you copied the code because the code should not
compile otherwise.
Original comment by manuel.carrasco.m
on 14 Dec 2012 at 8:07
[deleted comment]
but I cant add a Widget (e.g. Label) to jsPane because .add only takes types of
GQuery
Original comment by thomas.b...@gmail.com
on 14 Dec 2012 at 8:19
[deleted comment]
You are right, the problem is that you have to call widget after panel()
1. com.google.gwt.user.client.ui.Panel jsPane =
$(".jspPane").as(Widgets.Widgets).panel().widget();
2. jsPane.add(myWidget);
Original comment by manuel.carrasco.m
on 14 Dec 2012 at 8:27
[deleted comment]
This code works for me (with the last snapshot)
import com.google.gwt.user.client.ui.*;
import static com.google.gwt.query.client.GQuery.*;
public class Test implements EntryPoint {
public void onModuleLoad() {
$("<div class='aa'>Hola</div>").appendTo(document);
Panel p =GQuery.$(".aa").as(Widgets).panel().widget();
p.add(new Label("Hello"));
}
}
Original comment by manuel.carrasco.m
on 14 Dec 2012 at 8:33
Thanks for your help!
The code works, unfortunately not with the .jspPane (it's under plenty of divs)
I get the Exception caught: A widget that has an existing parent widget may not
be added to the detach list
Don't know if there is any way around it.
But thanks for your effort!
Original comment by thomas.b...@gmail.com
on 14 Dec 2012 at 9:22
Attach a project with enough stuff to reproduce the issue and I will take a
look.
Original comment by manuel.carrasco.m
on 15 Dec 2012 at 12:23
okay, here is the project.
Original comment by thomas.b...@gmail.com
on 15 Dec 2012 at 10:48
Attachments:
I see the problem, your html looks like
<div id="main">
<div class = "test">
</div>
</div>
And your code is:
RootPanel p1 = RootPanel.get("main"); [1]
p1.add(new Label("Hello123"));
Panel p = GQuery.$(".test").as(Widgets).panel().widget(); [2]
p.add(new Label("Hello"));
When you call [2], the 'main' div is promoted to a gwt panel and all its
content is added to the gwt dettach list in [1]. So you cannot add again the
div 'test' because it is part of a gwt widget.
You can fix your problem in two ways:
1.- Take the 'test' div out of 'main' one
<div id="main">
</div>
<div class = "test">
</div>
2.- Detach the 'test' div from the dom using gquery, and promote it to a new
panel, then add the new panel to the main.
RootPanel p1 = RootPanel.get("main");
p1.add(new Label("Hello123"));
GQuery test = $(".test", p1).remove();
Panel p = test.as(Widgets).panel().widget();
p.add(new Label("Hello"));
p1.add(p);
Original comment by manuel.carrasco.m
on 17 Dec 2012 at 9:10
This issue was closed by revision 6245b30fd12f.
Original comment by manuel.carrasco.m
on 17 Dec 2012 at 11:44
Thomas, after thinking a bit more about the issue, I think your use case should
be handled by gquery and I've released a fix which allows to promote any
dom-element to a gwt-panel, even when it is inside an already attached one.
Check out the last snapshot and test your code.
Thanks for reporting
- Manolo
Original comment by manuel.carrasco.m
on 17 Dec 2012 at 11:52
Original comment by manuel.carrasco.m
on 22 Dec 2012 at 11:57
Original issue reported on code.google.com by
thomas.b...@gmail.com
on 14 Dec 2012 at 4:27