通过Gwt.create(Interface.class),根据自己给定规则,自动生成InterfaceImpl类:
1.定义exportGenerator 模块
xml代码
- < module>
-
- < inherits name='com.google.gwt.user.User'/>
-
- < generate-with class="exporter.rebind.ExporterHelperGenerator" >
- < when-type-assignable class="exporter.client.IExportableHelper"/>
- < /generate-with>
-
- < /module>
interface 接口继承IExportableHelper,通过ExporterHelperGenerator自动构造.
2.创建SourceWrite写文件:
java 代码
- PrintWriter printWriter = ctx.tryCreate(logger, packageName,generatedSimpleName);
-
-
- ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(packageName, generatedSimpleName);
-
- composerFactory.addImport(JavaScriptObject.class.getName());
-
- composerFactory.addImplementedInterface(serviceInterfaceClassType.getSimpleSourceName());
-
-
- SourceWriter sw = composerFactory.createSourceWriter(ctx,printWriter);
3.至此,通过 SourceWrite 写我们想要自动生成的方法
java 代码
- sw.println( " public native void method1( ) /*-{ " );
-
- sw.indent();
-
- sw.println( " alert( ' hello! ' )" );
-
- sw.outdent();
-
- sw.println(" } -*/");
- sw.commit(TreeLogger);
分享到:
相关推荐
基于java的开发源码-Spring4GWT.zip 基于java的开发源码-Spring4GWT.zip 基于java的开发源码-Spring4GWT.zip 基于java的开发源码-Spring4GWT.zip 基于java的开发源码-Spring4GWT.zip 基于java的开发源码-Spring4GWT....
配置GWT.ui.xml代码提示解决eclipse打开***.ui.xml文件卡死的问题 压缩包里有配置步骤
进阶GWT.doc 进阶GWT.doc 进阶GWT.doc 进阶GWT.doc
入门GWT.doc 入门GWT.doc 入门GWT.doc 入门GWT.doc
包含GWT插件的eclipse,直接解压可以使用。 Google Web Toolkit(GWT Web Toolkit,简写:GWT)允许开发人员使用 Java 编程语言快速构建和维护复杂但性能高的 JavaScript 前端应用程序的工具集,能够降低开发难度,...
iteratee.zip,猫的CoreIteratees
Manning.GWT.in.Practice
Manning.GWT.in.Practice.Apr.2008
Accelerated.GWT.Building.Enterprise.Google.Web.Toolkit.Applications
Packt.Google.App.Engine.Java.and.GWT.Application.Development
Packt.Google.App.Engine.Java.and.GWT.Application.Development.Source.Code
Apress.Pro.Web.2.0.Application.Development.with.GWT.May.2008.pdf
如果尝试使用常规测试示例,那么会遇到这个错误:ERROR: GWT.create() is only usable in client code! It cannot be called, for example, from server code. If you are running a unit ...
org.liveSense.sample.gwt.notes.zip,livesense gwt rpc samplelivesense gwt示例
Addison.Wesley.Essential.GWT.Building.for.the.Web.with.Google.Web.Toolkit.2
in.cypal.studio.gwt.samples_1.0.0.200808282244.jar
in.cypal.studio.gwt.core_1.0.0.200808282244.jar
GWT.create-workshop:Vaadin和Sass响应式布局研讨会的源代码
基于Java的Spring4GWT.zip