Hi,
After a bit more investigation I found this post (GWT layout gotcha) -
> http://turbomanage.wordpress.com/2010/01/12/gwt-layout-gotcha/ on
David Chandler's blog.
Which states "One gotcha I’ve found is that you must be careful not to
attach a widget to a DIV nested inside a DIV that is attached to a
widget."
->
public class DashboardsView extends
ViewWithUiHandlers<DashboardsUiHandlers> implements
DashboardsPresenter.MyView {
private static final String CONTEXT_AREA_WIDTH = "*";
private static String html = "<div id=\"chart_nested_div\"> </div>
\n";
private VLayout panel;
private HTMLFlow htmlFlow;
private PieChart pie;
public DashboardsView() {
panel = new VLayout();
panel.setWidth(CONTEXT_AREA_WIDTH);
htmlFlow = new HTMLFlow(html);
panel.addMember(htmlFlow);
loadVisualizationApi();
}
@Override
public Widget asWidget() {
return panel;
}
public void loadVisualizationApi() {
Log.debug("loadVisualizationApi()");
// Create a callback to be called when the visualization API has
been loaded.
Runnable onLoadCallback = new Runnable() {
public void run() {
Log.debug("onLoadCallback()");
pie = new PieChart(createTable(), createOptions());
RootPanel.get("chart_sibling_div").add(pie);
// RootPanel.get("chart_nested_div").add(pie);
}
};
// Load the visualization api, passing the onLoadCallback to be
called when loading is complete.
VisualizationUtils.loadVisualizationApi("1.1", onLoadCallback,
PieChart.PACKAGE);
}
->
Host file:
->
<body>
<div id="loading" style="display: block;position: absolute;top:
50%;left: 50%;
text-align: center;font-family: Tahoma, Verdana, sans-
serif;font-size: 11px;">
Loading
<img src="images/loading.gif" />
</div>
<!-- OPTIONAL: include this if you want history support -->
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1'
style="position: absolute; width: 0; height: 0; border:
0">
</iframe>
<div id="chart_sibling_div"> </div>
</body>
->
The call to RootPanel.get("chart_sibling_div").add(pie) works as
expected (albeit the chart isn't where I'd like it to be). However,
the same call (using a nested div)
"RootPanel.get("chart_nested_div").add(pie)" fails as per David's post
[ERROR] Uncaught exception escaped
java.lang.AssertionError: A widget that has an existing parent widget
may not be added to the detach list
at
com.google.gwt.user.client.ui.RootPanel.detachOnWindowClose(RootPanel.java:
122)
N.B. The application (http://code.google.com/p/crmdipity/) uses
smartGWT nested layout containers to achieve a look very similar to a
GWT's SplitLayoutPanel.
See also -> http://code.google.com/p/google-web-toolkit/issues/detail?id=3511
Sample code and screen shot ->
http://forums.smartclient.com/showthread.php?t=16703
Any suggestions much appreciated :-)
Cheers
Rob
On May 10, 9:05 am, Rob <[email protected]> wrote:
> Hi Eric,
>
> Thanks for getting back to me.
>
> ->http://code.google.com/p/gwt-google-apis/issues/detail?id=425
>
> Yes, I found that post yesterday and that's why I moved from smartGWT
> 2.4 to the latest smartGWT nightly build (2.5).
>
> -> making sure you aren't moving any widgets from one parent to
> another
>
> I think its a smartGWT-related issue
> ->http://forums.smartclient.com/showthread.php?t=16703
>
> I also posted here because of this post
> ->http://groups.google.com/group/google-visualization-api/browse_thread...
>
> Although it might also be GWTP-related.
>
> As you suggested I'll set some breakpoints and see how I go.
>
> Cheers
> Rob
>
> On May 10, 2:31 am, Eric Ayers <[email protected]> wrote:
>
> > First of all, there was an issue a lot of SmartGWT users ran into
> > w/r/t visualization I wanted you to be aware of.
>
> >http://code.google.com/p/gwt-google-apis/issues/detail?id=425
>
> > The message you're getting doesn't sound specific to the visualization
> > API, it sounds more like a general GWT or smart GWT problem. As a
> > general debugging tip, I'd recommend setting break points in dev mode
> > and making sure you aren't moving any widgets from one parent to
> > another and you aren't accidentally getting a callback more than once.
>
> > On Sun, May 8, 2011 at 9:44 PM, Rob <[email protected]> wrote:
> > > Hi
>
> > > I would like to add visualization support via the Google Visualization
> > > API (1.1) to an existing GWT (2.1.1) and smartGWT (2.4) application.
>
> > > I followed the approach described in this post ->
> > >http://forums.smartclient.com/showpost.php?p=37754&postcount=2andthe
> > > Visualization Getting Started guide->
> > >http://code.google.com/p/gwt-google-apis/wiki/VisualizationGettingSta....
>
> > > And, then found this post ->
> > >http://groups.google.com/group/google-visualization-api/browse_thread...
> > > in the Google Visualization API discussion group.
>
> > > For example:
>
> > > ->
>
> > > public void loadVisualizationApi() {
>
> > > Log.debug("loadVisualizationApi()");
>
> > > // Create a callback to be called when the visualization API
> > > // has been loaded.
> > > Runnable onLoadCallback = new Runnable() {
> > > public void run() {
>
> > > Log.debug("onLoadCallback()");
>
> > > // Create a pie chart visualization.
> > > pie = new PieChart(createTable(), createOptions());
> > > pie.setWidth("80%");
>
> > > Canvas canvas = new Canvas();
> > > canvas.setID("sys_pie_canvas");
> > > canvas.setWidth100();
> > > canvas.setHeight("50%");
> > > canvas.addChild(pie);
>
> > > panel.addMember(canvas, 0);
>
> > > Log.debug("panel.addMember(canvas, 0)");
> > > }
> > > };
>
> > > // Load the visualization api, passing the onLoadCallback
> > > // to be called when loading is complete.
> > > VisualizationUtils.loadVisualizationApi("1.1", onLoadCallback,
> > > PieChart.PACKAGE);
> > > }
>
> > > // The code for createTable() and createOptions()) is as per
> > > // the post mentioned above.
>
> > > ->
>
> > > However, this results in the following error:
> > > java.lang.AssertionError: A widget that has an existing parent widget
> > > may not be added to the detach list at
> > > com.google.gwt.user.client.ui.RootPanel.detachOnWi
> > > ndowClose(RootPanel.java:136) when using GWT (2.1.1), smartGWT LGPL
> > > (2.5 nightly build) and Google Visualization API (1.1).
>
> > > Note: I also tested the code using smartGWT (2.4) and received the
> > > following error: (NativeMethodAccessorImpl.java:-2) 2011-05-09
> > > 10:26:21,613 [FATAL] Uncaught JavaScript exception [Script error.]
> > > in , line 0
>
> > > If I comment out the call to "panel.addMember(pie)" and replace it
> > > with "RootPanel.get().add(pie)" no exception is thrown and the "chart"
> > > is rendered correctly (you can see it momentarily if you re-size the
> > > browser window) but as a child of the root panel. Which means it is
> > > hidden by the application's other nested layout containers (e.g.
> > > North, West, East and South).
>
> > > I would like to be able to place the "chart" in a nested layout
> > > container if possible?
>
> > > The stack trace:
>
> > > ->
>
> > > 16:13:50.134 [ERROR] [serendipity] (ExceptionHelper.java:38)
> > > 2011-05-08 16:13:50,134 [FATAL] Uncaught Exception:
>
> > > java.lang.AssertionError: A widget that has an existing parent widget
> > > may not be added to the detach list
> > > at
> > > com.google.gwt.user.client.ui.RootPanel.detachOnWindowClose(RootPanel.java:
> > > 136)
> > > at com.google.gwt.user.client.ui.RootPanel.get(RootPanel.java:211)
> > > at
> > > com.smartgwt.client.widgets.WidgetCanvas.onDraw(WidgetCanvas.java:39)
> > > at com.smartgwt.client.widgets.BaseWidget.rendered(BaseWidget.java:
> > > 242)
> > > at sun.reflect.GeneratedMethodAccessor40.invoke(Unknown Source)
> > > at
> > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
> > > 25)
> > > at java.lang.reflect.Method.invoke(Method.java:597)
> > > at
> > > com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
> > > at
> > > com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
> > > at
> > > com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:
> > > 157)
> > > at
> > > com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:
> > > 326)
> > > at
> > > com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:
> > > 207)
> > > at
> > > com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:
> > > 126)
> > > at
> > > com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:
> > > 561)
> > > at
> > > com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:
> > > 289)
> > > at
> > > com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:
> > > 107)
> > > at
> > > com.smartgwt.client.widgets.layout.Layout.addMemberPostCreate(Layout.java)
> > > at com.smartgwt.client.widgets.layout.Layout.addMember(Layout.java:
> > > 1089)
> > > at com.smartgwt.client.widgets.layout.Layout.addMember(Layout.java:
> > > 1076)
> > > at au.com.uptick.serendipity.client.sales.view.DashboardsView
> > > $1.run(DashboardsView.java:76)
> > > at
> > > com.google.gwt.ajaxloader.client.ExceptionHelper.runProtected(ExceptionHelper.java:
> > > 36)
> > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > > at
> > > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
> > > 39)
> > > at
> > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
> > > 25)
> > > at java.lang.reflect.Method.invoke(Method.java:597)
> > > at
> > > com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
> > > at
> > > com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
> > > at
> > > com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:
> > > 157)
> > > at
> > > com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:
> > > 281)
> > > at
> > > com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:
> > > 531)
> > > at
> > > com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:
> > > 352)
> > > at java.lang.Thread.run(Thread.java:619)
>
> > > ->
>
> > > Cheers
> > > Rob
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "Google Visualization API" group.
> > > To post to this group, send email to
> > > [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected].
> > > For more options, visit this group
> > > athttp://groups.google.com/group/google-visualization-api?hl=en.
>
> > --
> > Eric Z. Ayers
> > Google Web Toolkit, Atlanta, GA USA
>
>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.