Hi, I am new to SmartGWT as well as with the Visualization API from Google.
Right now I'm trying to make those two work together, but I can't manage to find what I do wrong. So I'm asking for help.
I use this VLayout to make my main panel which consist in a header and the container of the Graph (it's a PieChart).
Here is the code (I use the latest vertions of GWT, Smart and Visu.).
I keep on getting this StackTrace.
I tried _many_ others workaround but nothing seem to work.
Any pointers ?
TY.
Right now I'm trying to make those two work together, but I can't manage to find what I do wrong. So I'm asking for help.
I use this VLayout to make my main panel which consist in a header and the container of the Graph (it's a PieChart).
Here is the code (I use the latest vertions of GWT, Smart and Visu.).
Code:
import com.google.gwt.visualization.client.AbstractDataTable;
import com.google.gwt.visualization.client.DataTable;
import com.google.gwt.visualization.client.VisualizationUtils;
import com.google.gwt.visualization.client.AbstractDataTable.ColumnType;
import com.google.gwt.visualization.client.visualizations.PieChart;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.VLayout;
public class FloWatchMainPanel extends VLayout {
public FloWatchMainPanel() {
HLayout header = new HLayout();
header.setMembers(new Label("test"), new IButton("Logout"));
header.setStyleName("target-header");
header.setLayoutMargin(15);
header.setHeight(50);
header.setAlign(Alignment.RIGHT);
addMember(header);
addMember(new Graphic());
}
public class Graphic extends HLayout {
public Graphic() {
Runnable onLoadCallback = new Runnable() {
public void run() {
addMember(new PieChart(createTablePie(), createOptionsPie()));
}
};
VisualizationUtils.loadVisualizationApi(onLoadCallback, PieChart.PACKAGE);
}
private PieChart.Options createOptionsPie() {
PieChart.Options options = PieChart.Options.create();
options.setWidth(400);
options.setHeight(240);
options.set3D(true);
options.setBorderColor("white");
options.setTitle("GWT Chart test.");
return options;
}
private AbstractDataTable createTablePie() {
DataTable data = DataTable.create();
data.addColumn(ColumnType.STRING, "Data set");
data.addColumn(ColumnType.NUMBER, "Value");
data.addRows(3);
data.setValue(0, 0, "Data set 1");
data.setValue(0, 1, 100);
data.setValue(1, 0, "Data set 2");
data.setValue(1, 1, 10);
data.setValue(2, 0, "Data set 3");
data.setValue(2, 1, 20);
return data;
}
}
}
Code:
10:31:27.089 [ERROR] [flw8_3client] 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: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:205)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:1713)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:165)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:284)
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:995)
at com.smartgwt.client.widgets.layout.Layout.addMember(Layout.java:982)
at com.banctec.flw.client.view.FloWatchMainPanel$Graphic$1.run(FloWatchMainPanel.java:33)
at com.google.gwt.ajaxloader.client.ExceptionHelper.runProtected(ExceptionHelper.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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.BrowserChannel.reactToMessages(BrowserChannel.java:1668)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:401)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
at java.lang.Thread.run(Unknown Source)
Any pointers ?
TY.
Comment