0

我创建了一个 SmartGWT 应用程序,它显示一个 UI 对话框(在对话框中显示一些控件)。

这个对话框应用程序已经过测试并且运行良好,但现在我必须将它作为 jar 文件分发,以便其他 SmartGWT 项目可以将它用作小部件。

我正在寻找一种方法,如何将此组件“RemoteFileDialog”作为 jar 文件发送,以便任何其他 SmartGWT Web 应用程序都可以使用它来显示文件浏览器。是否有任何详细的文件/参考资料可以让我完全理解?

我使用 jar cvf ... 命令为此对话框应用程序创建了 jar 文件。

当我在目标 smartGwt 示例项目中使用此 .jar 时,无法找到 .jar 中包含的类

可以肯定的是,我在 eclipse ide 中执行了以下步骤。

  1. 通过“添加外部 jars”将 jar 添加到构建路径

  2. 模块继承:更改 gwt.xml 文件

3 做 gwtc 测试模块是否正确继承。GWT 编译工作没有警告或错误。

但是,当我尝试在下面给出的测试代码中创建对话框类的实例(jar 文件的一部分)时,eclipse 无法识别或提示我添加所需的导入,就像它对所有其他 jar 文件所做的那样. 代码:

即使我自己手动添加了 import 语句,它仍然会在这些行出现编译错误。

我想要一种从 SmartGWT 项目创建 .jar 文件的正确方法,以便它可以在另一个 smartGWT 项目中用作 .jar 文件。

任何帮助和线索都非常感谢..

这是我的环境,如果有意义的话:!

SmartGWT 3.0 GWT 2.4 浏览器:Firefox 7.0.1 开发环境:Ubuntu11.10 上的 Eclipse Indigo

问候,房车

添加 .gwt.xml 文件的内容...

这个为widget项目文件:RemoteFileBrowser.gwt.xml

<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='remotefilebrowser'>
<!-- Inherit the core Web Toolkit stuff.                        -->
<inherits name='com.google.gwt.user.User'/>

<!-- Inherit the default GWT style sheet.  You can change       -->
<!-- the theme of your GWT application by uncommenting          -->
<!-- any one of the following lines.                            -->
<inherits name='com.google.gwt.user.theme.clean.Clean'/>
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/>     -->

<!-- Other module inherits                                      -->
<inherits name='com.smartgwt.SmartGwt'></inherits>
<inherits name="com.smartgwt.tools.SmartGwtTools"></inherits>
<!-- Specify the app entry point class.                         -->
<entry-point class='com.comviva.remotefilebrowser.client.RemoteFileBrowser'/>

<!-- Specify the paths for translatable code                    -->
<source path='client'/>
<source path='shared'/>

</module>

这个用于使用小部件的宿主项目:文件:GWTSample.gwt.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <module rename-to='gwtsample'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' />

<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.clean.Clean' />
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<inherits name="com.smartgwt.SmartGwt" />
<!-- <inherits name="com.comviva.scheduler.SchedulerWidget"></inherits> -->
<inherits name="com.comviva.remotefilebrowser.RemoteFileBrowser"></inherits>
<inherits name="com.smartgwt.tools.SmartGwtTools"></inherits>

<!-- Other module inherits -->

<!-- Specify the app entry point class. -->
<entry-point class='com.rv.gwtsample.client.GWTSample' />

<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />

    </module>
4

2 回答 2

0

在您的RemoteFileBrowser.gwt.xml中,您可以使用以下命令将模块重命名为更简单的名称:

<module rename-to='com.foo.MyModule'>

然后,当在另一个项目中包含这个“小部件”时,你可以这样做:

<inherits name="com.foo.MyModule" />

检查此链接以获取更多信息:https ://developers.google.com/web-toolkit/doc/latest/DevGuideOrganizingProjects

注意,模块名区分大小写

于 2012-05-16T12:07:05.033 回答
0

经过一番挣扎,我可以找到解决方案,在下面发布,因为这可能对像我这样的其他新手有用:)

  • 构建jar文件的方式不正确。
  • 由于我手动创建了一个 .jar 文件(不是通过 eclipse),它没有在 com/comviva/remotefilebrowser/*.class 下添加我的 RemoteFileDialog 的 .class 文件。相反,类文件是从 /war/WEB-INF/classes 等位置添加的。
  • 因此,即使导入了 .jar,也无法识别它。

我现在使用 eclipse 导出选项创建 .jar 并选择要包含的文件/资源​​列表。

于 2012-05-17T08:42:58.343 回答