私は GWT-P の初心者ですが、このトピックに関する資料はほとんどありません。テスト目的で、単純な円グラフ ウィジェットを作成しようとしています。ウィジェットのプレゼンター、ビュー、UiBinder を作りました。
package com.rs.gwtp.gametestingyou.client;
import com.gwtplatform.mvp.client.PresenterWidget;
import com.gwtplatform.mvp.client.View;
import com.google.inject.Inject;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.HTMLPanel;
public class PieChartPresenter extends
PresenterWidget<PieChartPresenter.MyView> {
public interface MyView extends View {
public HTMLPanel getChartPanel();
public void drawPieChart();
}
@Inject
public PieChartPresenter(final EventBus eventBus, final MyView view) {
super(eventBus, view);
}
@Override
protected void onBind() {
super.onBind();
}
/*Ovde prmeniti method*/
@Override
protected void onReset() {
super.onReset();
/*MyView v = getView();
v.drawPieChart();*/
getView().drawPieChart();
}
}
次に、表示します。
package com.rs.gwtp.gametestingyou.client;
import com.gwtplatform.mvp.client.ViewImpl;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiConstructor;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.visualization.client.AbstractDataTable;
import com.google.gwt.visualization.client.AbstractDataTable.ColumnType;
import com.google.gwt.visualization.client.DataTable;
import com.google.gwt.visualization.client.visualizations.corechart.Options;
import com.google.gwt.visualization.client.visualizations.corechart.PieChart;
import com.google.inject.Inject;
public class PieChartView extends ViewImpl implements PieChartPresenter.MyView {
private final Widget widget;
@UiField HTMLPanel chartPanel;
@UiField (provided=true) PieChart pieChart;
public interface Binder extends UiBinder<Widget, PieChartView> {
}
@Inject
public @UiConstructor PieChartView(final Binder binder) {
widget = binder.createAndBindUi(this);
pieChart = new PieChart(createTable(), createOptions());
chartPanel.add(pieChart);
}
@Override
public Widget asWidget() {
return widget;
}
public HTMLPanel getChartPanel(){
return chartPanel;
}
@Override
public void drawPieChart() {
// OVAJ POKUSAJ
pieChart.draw(createTable(),createOptions());
}
private Options createOptions() {
Options options = Options.create();
options.setWidth(400);
options.setHeight(240);
options.setTitle("My Daily Activities");
return options;
}
private AbstractDataTable createTable() {
DataTable data = DataTable.create();
data.addColumn(ColumnType.STRING, "Task");
data.addColumn(ColumnType.NUMBER, "Hours per Day");
data.addRows(2);
data.setValue(0, 0, "Work");
data.setValue(0, 1, 14);
data.setValue(1, 0, "Sleep");
data.setValue(1, 1, 10);
return data;
}
}
そして最後のUiBinder
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'
ui:generateFormat='com.google.gwt.i18n.rebind.format.PropertiesFormat'
ui:generateKeys='com.google.gwt.i18n.rebind.keygen.MD5KeyGenerator'
ui:generateLocales='default'
xmlns:c="urn:import:com.google.gwt.visualization.client.visualizations.corechart" xmlns:v="urn:import:com.google.gwt.visualization.client.visualizations">
<g:HTMLPanel ui:field="chartPanel">
<c:PieChart ui:field="pieChart" ></c:PieChart>
</g:HTMLPanel>
</ui:UiBinder>
このコードをロードすると、Error: [ERROR] [gametestingyou] - Unable to load module entry point class com.rs.gwtp.gametestingyou.client.GameTestingYou (詳細については関連する例外を参照) と Umbrella 例外が発生します。
助けてください :) !
これは完全な例外です:
19:14:34.890 [エラー] [gametestingyou] モジュール エントリ ポイント クラス com.rs.gwtp.gametestingyou.client.GameTestingYou をロードできません (詳細については、関連する例外を参照してください) com.google.gwt.event.shared.UmbrellaException: 1 つまたはより多くの例外がキャッチされました。com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:129) の UmbrellaException#getCauses の完全なセットを参照してください。 .java:75) com.google.gwt.event.logical.shared.ValueChangeEvent.fire(ValueChangeEvent.java:43) で com.google.gwt.user.client.impl.HistoryImpl.fireHistoryChangedImpl(HistoryImpl.java:82) で) com.google.gwt.user.client.History.fireCurrentHistoryState(History.java:121) で com.gwtplatform.mvp.client.proxy.PlaceManagerImpl.revealCurrentPlace(PlaceManagerImpl.java:310) で com.rs.gwtp.gametestingyou.client.GameTestingYou.onModuleLoad(GameTestingYou.java:17) の sun.reflect.NativeMethodAccessorImpl.invoke0(ネイティブ メソッド) の sun.reflect.NativeMethodAccessorImpl.invoke(不明なソース) の sun.reflect.DelegatingMethodAccessorImpl.invoke(不明なソース) com.google.gwt.dev.shell.OophmSessionHandler.loadModule( com.google.gwt.dev.shell.OophmSessionHandler.loadModule( OophmSessionHandler.java:200) で com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525) で com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363) で java .lang.Thread.run (不明なソース) 原因: com.google.gwt.event.shared.UmbrellaException: 1 つ以上の例外がキャッチされました。com.google.gwt.event.shared.EventBus.castFireEventFromSource(EventBus.java:77) の UmbrellaException#getCauses の完全なセットを参照してください。 com.gwtplatform.mvp.client.proxy.PlaceManagerImpl.fireEvent(PlaceManagerImpl.java:146) com.gwtplatform.mvp.client.proxy.PlaceManagerImpl.doRevealPlace(PlaceManagerImpl.java:121) com.gwtplatform.mvp.client. proxy.PlaceManagerImpl.revealPlace(PlaceManagerImpl.java:339) で com.rs.gwtp.gametestingyou.client.place.ClientPlaceManager.revealDefaultPlace(ClientPlaceManager.java:24) で com.gwtplatform.mvp.client.proxy.PlaceManagerImpl.onValueChange( PlaceManagerImpl.java:264) の com.google.gwt.event.logical.shared.ValueChangeEvent.dispatch(ValueChangeEvent.java:128) の com.google.gwt.event.logical.shared.ValueChangeEvent.dispatch(ValueChangeEvent.java:1) at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1) at com.google.web.bindery.event.shared.EventBus.dispatchEvent( EventBus.java:40) com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193) com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java: 88) com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127) で com.google.gwt.user.client.impl.HistoryImpl.fireEvent(HistoryImpl.java:75) で com.google .gwt.event.logical.shared.ValueChangeEvent.fire(ValueChangeEvent.java:43) com.google.gwt.user.client.impl.HistoryImpl.fireHistoryChangedImpl(HistoryImpl.java:82) com.google.gwt.user でcom.gwtplatform.mvp の .client.History.fireCurrentHistoryState(History.java:121)。client.proxy.PlaceManagerImpl.revealCurrentPlace(PlaceManagerImpl.java:310) at com.rs.gwtp.gametestingyou.client.GameTestingYou.onModuleLoad(GameTestingYou.java:17) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun. com.google.gwt.dev.shell.ModuleSpace.onLoad( で java.lang.reflect.Method.invoke(未知のソース) で、sun.reflect.DelegatingMethodAccessorImpl.invoke(未知のソース) で、reflect.NativeMethodAccessorImpl.invoke(未知のソース)( ModuleSpace.java:396) com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200) で com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525) で.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363) java.lang.Thread.run(不明なソース) 原因: java.lang.NullPointerException: com.rs.gwtp.gametestingyou.client.PieChartView_BinderImpl.createAndBindUi(PieChartView_BinderImpl.java:33) で com.google.gwt.user.client.ui.HTMLPanel.addAndReplaceElement(HTMLPanel.java:197) で null。 rs.gwtp.gametestingyou.client.PieChartView_BinderImpl.createAndBindUi(PieChartView_BinderImpl.java:1) at com.rs.gwtp.gametestingyou.client.PieChartView.(PieChartView.java:27) at com.rs.gwtp.gametestingyou.client.gin .ClientGinjectorImpl.com$rs$gwtp$gametestingyou$client$PieChartView_PieChartView_methodInjection(ClientGinjectorImpl.java:555) com.rs.gwtp.gametestingyou.client.gin.ClientGinjectorImpl.create_Key$type$com$rs$gwtp$gametestingyou$client$ PieChartView$_annotation$$none$$(ClientGinjectorImpl.java:559) com.rs.gwtp.gametestingyou.client.gin.ClientGinjectorImpl.get_Key$type$com$rs$gwtp$gametestingyou$client$PieChartView$_annotation$$none$$(ClientGinjectorImpl.java:570) at com.rs.gwtp.gametestingyou.client.gin.ClientGinjectorImpl.create_Key$type$com$ rs$gwtp$gametestingyou$client$PieChartPresenter$MyView$_annotation$$none$$(ClientGinjectorImpl.java:1726) at com.rs.gwtp.gametestingyou.client.gin.ClientGinjectorImpl.get_Key$type$com$rs$gwtp$ gametestingyou$client$PieChartPresenter$MyView$_annotation$$none$$(ClientGinjectorImpl.java:1735) at com.rs.gwtp.gametestingyou.client.gin.ClientGinjectorImpl.create_Key$type$com$rs$gwtp$gametestingyou$client$ PieChartPresenter$_annotation$$none$$(ClientGinjectorImpl.java:1522) at com.rs.gwtp.gametestingyou.client.gin.ClientGinjectorImpl.get_Key$type$com$rs$gwtp$gametestingyou$client$PieChartPresenter$_annotation$$none $$(ClientGinjectorImpl.java:1533) com.rs.gwtp.gametestingyou.client.gin.ClientGinjectorImpl.memberInject_Key$type$com$rs$gwtp$gametestingyou$client$ShowTestResultsPresenter$_annotation$$none$$(ClientGinjectorImpl.java:2069) com.rs .gwtp.gametestingyou.client.gin.ClientGinjectorImpl.create_Key$type$com$rs$gwtp$gametestingyou$client$ShowTestResultsPresenter$_annotation$$none$$(ClientGinjectorImpl.java:2079) at com.rs.gwtp.gametestingyou.client .gin.ClientGinjectorImpl.get_Key$type$com$rs$gwtp$gametestingyou$client$ShowTestResultsPresenter$_annotation$$none$$(ClientGinjectorImpl.java:2092) at com.rs.gwtp.gametestingyou.client.gin.ClientGinjectorImpl.memberInject_Key $type$com$rs$gwtp$gametestingyou$client$HomePagePresenter$_annotation$$none$$(ClientGinjectorImpl.java:1341) at com.rs.gwtp.gametestingyou.client.gin.ClientGinjectorImpl.create_Key$type$com$rs$gwtp$gametestingyou$client$HomePagePresenter$_annotation$$none$$(ClientGinjectorImpl.java:1352) at com.rs.gwtp.gametestingyou.client.gin.ClientGinjectorImpl.get_Key$type$com$ rs$gwtp$gametestingyou$client$HomePagePresenter$_annotation$$none$$(ClientGinjectorImpl.java:1365) at com.rs.gwtp.gametestingyou.client.gin.ClientGinjectorImpl.access$4(ClientGinjectorImpl.java:1363) at com. rs.gwtp.gametestingyou.client.gin.ClientGinjectorImpl$5$1.onSuccess(ClientGinjectorImpl.java:1413) at com.google.gwt.core.client.GWT.runAsync(GWT.java:255) at com.rs.gwtp. gametestingyou.client.gin.ClientGinjectorImpl$5.get(ClientGinjectorImpl.java:1411) com.gwtplatform.common.client.CodeSplitProvider.get(CodeSplitProvider.java:48) com.gwtplatform.mvp.client.proxy.ProxyImpl.getPresenter で(ProxyImpl.java:46) com で。gwtplatform.mvp.client.proxy.ProxyPlaceAbstract.handleRequest(ProxyPlaceAbstract.java:193) com.gwtplatform.mvp.client.proxy.ProxyPlaceAbstract.access$0(ProxyPlaceAbstract.java:192) com.gwtplatform.mvp.client.proxy で.ProxyPlaceAbstract$1.onPlaceRequest(ProxyPlaceAbstract.java:143) at com.gwtplatform.mvp.client.proxy.PlaceRequestInternalEvent.dispatch(PlaceRequestInternalEvent.java:134) at com.gwtplatform.mvp.client.proxy.PlaceRequestInternalEvent.dispatch(PlaceRequestInternalEvent. java:1) com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1) で com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40) で.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193) com.google.web.bindery.event.shared.SimpleEventBus.fireEventFromSource(SimpleEventBus.java:96) com.google.gwt.event.shared.SimpleEventBus.fireEventFromSource(SimpleEventBus.java:62) で com.google.gwt.event.shared.EventBus.castFireEventFromSource(EventBus.java:75) で com.google.gwt .event.shared.SimpleEventBus.fireEventFromSource(SimpleEventBus.java:67) com.gwtplatform.mvp.client.proxy.PlaceManagerImpl.fireEvent(PlaceManagerImpl.java:146) com.gwtplatform.mvp.client.proxy.PlaceManagerImpl.doRevealPlace (PlaceManagerImpl.java:121) com.gwtplatform.mvp.client.proxy.PlaceManagerImpl.revealPlace(PlaceManagerImpl.java:339) com.rs.gwtp.gametestingyou.client.place.ClientPlaceManager.revealDefaultPlace(ClientPlaceManager.java:24) ) com.google.gwt.event.logical.shared.ValueChangeEvent の com.gwtplatform.mvp.client.proxy.PlaceManagerImpl.onValueChange(PlaceManagerImpl.java:264) で。com.google.gwt.event.logical.shared.ValueChangeEvent.dispatch(ValueChangeEvent.java:1) でのディスパッチ (ValueChangeEvent.java:128) com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java: 1) com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40) で com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193) で.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88) com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127) com.google.gwt.user で.client.impl.HistoryImpl.fireEvent(HistoryImpl.java:75) com.google.gwt.event.logical.shared.ValueChangeEvent.fire(ValueChangeEvent.java:43) で com.google.gwt.user.client.impl .HistoryImpl.fireHistoryChangedImpl(HistoryImpl.java:82) com.google.gwt.user.client.com.rs.gwtp.gametestingyou.client.GameTestingYou.onModuleLoad(GameTestingYou.java: 17) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) で sun.reflect.NativeMethodAccessorImpl.invoke(不明なソース) で sun.reflect.DelegatingMethodAccessorImpl.invoke(不明なソース) で java.lang.reflect.Method.invoke(不明)ソース) com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:396) com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200) com.google.gwt .dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525) com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363) java.lang.Thread.run (不明なソース) で
package com.rs.gwtp.gametestingyou.client;
import com.google.gwt.core.client.EntryPoint;
import com.rs.gwtp.gametestingyou.client.gin.ClientGinjector;
import com.google.gwt.core.client.GWT;
import com.gwtplatform.mvp.client.DelayedBindRegistry;
public class GameTestingYou implements EntryPoint {
private final ClientGinjector ginjector = GWT.create(ClientGinjector.class);
@Override
public void onModuleLoad() {
// This is required for Gwt-Platform proxy's generator
DelayedBindRegistry.bind(ginjector);
ginjector.getPlaceManager().revealCurrentPlace();
}
}