简体   繁体   English

在客户端使用第三方库和GWT?

[英]Using 3rd party libraries with GWT on client side?

I'm starting out with GWT and was wondering what libraries is it possible to use with GWT on the client side? 我开始使用GWT,并想知道在客户端可以使用哪些库与GWT? Because GWT converts Java code into JavaScript, I can't really imagine all conversions to be possible if you are just using the client side. 因为GWT将Java代码转换为JavaScript,所以如果您只是使用客户端,我无法想象所有转换都是可能的。

Of course you wouldn't wanna use everything on client side in a real application, but I'm wondering what are the physical possibilities of the converter? 当然,您不希望在实际应用程序中使用客户端的所有内容,但我想知道转换器的物理可能性是什么? Is there any kind of a list of supported libraries? 是否有任何类型的受支持库? How do you know if they can get converted to work with JavaScript? 你怎么知道他们是否可以转换为使用JavaScript? But I can imagine if you were to use something like Apache POI - it shouldn't work, right? 但我可以想象,如果你使用像Apache POI这样的东西 - 它应该不起作用,对吧?

I might be missing some basic understanding there too I guess... 我猜可能也会遗漏一些基本的理解...

These two links gives the jre compatibility provided with gwt. 这两个链接提供了与gwt一起提供的jre兼容性。 http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsCompatibility.html http://www.gwtproject.org/doc/latest/RefJreEmulation.html http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsCompatibility.html http://www.gwtproject.org/doc/latest/RefJreEmulation.html

Using other libraries with gwt 使用其他库与gwt

If you need to use third party libraries with gwt, you need to first convert that library into a gwt module . 如果您需要将第三方库与gwt一起使用,则需要先将该库转换为gwt模块 For creating a gwt module you need to put a modeulename.gwt.xml file in your library jar file. 要创建gwt模块,您需要将modeulename.gwt.xml文件放在库jar文件中。 The xml file should contain source tag ( <source path="path" /> )to the package which needs to be gwt compatible. xml文件应包含需要与gwt兼容的包的源标记( <source path="path" /> )。 (You also need to include the java source files to the jar. Class files will not get compiled to javascript) (您还需要将java源文件包含在jar中。类文件不会被编译为javascript)

Then you have to inherit your module to your gwt project. 然后你必须将你的模块继承到你的gwt项目。 For this add <inherits name="com.yourpackage.modeulename"/> to your projects gwt xml. 为此,将<inherits name="com.yourpackage.modeulename"/>到项目gwt xml中。 (replace the package and module name as on your library) (替换库中的包和模块名称)

Now you can compile the library into javascript.(Make sure that your library is not using any gwt incompatible codes like external libraries, incompatible jre codes etc. Or you can convert that libraries into get modules) 现在你可以将库编译成javascript。(确保你的库没有使用任何gwt不兼容的代码,如外部库,不兼容的jre代码等。或者你可以将这些库转换为get模块)

For further reference : GWT oraganising projects 供进一步参考: GWT组织项目

The page you are looking for in the GWT documentation is http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsCompatibility.html 您在GWT文档中寻找的页面是http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsCompatibility.html

There's a (generated) list of emulated Java Runtime classes and methods at http://www.gwtproject.org/doc/latest/RefJreEmulation.html (not always up-to-date, but it's a start) http://www.gwtproject.org/doc/latest/RefJreEmulation.html上有一个(生成的)模拟Java运行时类和方法列表(并不总是最新的,但它是一个开始)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM