我是GWT的新手。我有以下代码:
SomeClientServiceAsync someService = GWT.create(SomeClientService.class);
上面这行代码是什么意思,为什么不能使用其他方式实例化它?
请帮帮我!
谢谢。
我是GWT的新手。我有以下代码:
SomeClientServiceAsync someService = GWT.create(SomeClientService.class);
上面这行代码是什么意思,为什么不能使用其他方式实例化它?
请帮帮我!
谢谢。
GWT.create
用于延迟绑定。这允许您根据用户的浏览器提供相同服务的不同实现。请参见以下问题:
如果您不需要多个服务实现,只需通过 new
创建即可!
GWT.create有不同的工作方式:
例子:
<replace-with class="com.x.app.client.ui.base.button.CustomSlicedButtonCellAppearance">
<when-type-is class="com.x.app.client.ui.base.button.CustomButtonCellAppearance" />
<when-property-is name="gxt.css3.enabled" value="false"/>
<when-property-is name="gxt.theme" value="themeName" />
</replace-with>
<generate-with class="org.fusesource.restygwt.rebind.RestServiceGenerator">
<when-type-assignable class="org.fusesource.restygwt.client.RestService" />
</generate-with>