共享GWT模块中的图像资源(小部件) [英] Image resources in shared GWT modules (widgets like)

查看:98
本文介绍了共享GWT模块中的图像资源(小部件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在GWT中有很多类,代表图形小部件。它们被打包成 GWT 模块,称为 GWT-Toolbox 。这个模块目前只有客户端代码。这意味着,所有这些类主要是布局,窗口,我可以沿着其他 GWT-apps (单独模块)重复使用。


$ b $目前,我这样做的方式是,所有其他的 GWT-apps 继承这个 GWT-Toolbox module。



是否是正确的做法?

我的主要问题是关于图片资源。我想在 GWT-Toolbox 模块中使用一些图片,这些图片可以在所有 GWT-apps 中共享。



我可以做什么?我不想使用 ClientBundle ,因为它不符合我的需求。

我在哪里放置资源文件,以及如何将它们打包到 GWT-apps 为了记录,我使用GWT 2.4



EDIT



因此,在社区的帮助下,我想出了如何继续。请注意,此解决方案不使用 ClientBundle


$ b

GWT-Toolbox - 这是文件结构


-src / main / java

--- com.mypackage.toolbox

------公开

---------图片

------------ img1.png

------------ img2.png

--------- GWT-Toolbox.gwt.xml



里面的GWT-Toolbox源代码,请参考这样的图像:
$ b

  GWT.getModuleBaseURL() +images / img1.png

就是这样。



$ b是否是正确的做法?

绝对;这实际上与 com.google.gwt.user.User 模块中的小部件没有什么不同。
(提供继承意味着< inherits /> ,并将GWT-Toolbox JAR放入类路径中)


我在哪里放置我的资源文件,以及它们将如何打包到GWT应用程序中?


您可以将它们作为简单的资源放入您的JAR中,以便其他模块可以在 ClientBundle 中使用它们, code> @Source 。

或者你把它们放在 public 子文件夹中(确切地说, 公共路径,您的模块的子文件夹名称默认为 public 但实际上是可配置的),因此它们并排部署使用 *。cache。* 编译文件(这就是 theme 在GWT中的工作方式)。


I have many classes in GWT that represents graphical widgets. They are packaged as a GWT module called GWT-Toolbox. This module only have for now, client code. That means, all those classes are mainly layouts, windows, that I reuse along my others GWT-apps (separate modules).

For the moment, the way I'm doing this is that all my others GWT-apps inherits this GWT-Toolbox module.

Is it the right way of doing it ?

My main question is about images resources. I want to use in the GWT-Toolbox module, some images that would be shared along all GWT-apps.

What can I achieve that ? I don't want to use ClientBundle because it do not fit my needs.

Where do I put my resources files, and how they will be packaged in the GWT-apps ?

For the record, I'm using GWT 2.4

EDIT

So, with the help of the community, I figured out how to proceed. Note, that this solution doesn't use ClientBundle.

GWT-Toolbox - this is the files structure

-src/main/java
--- com.mypackage.toolbox
------ public
--------- images
------------ img1.png
------------ img2.png
--------- GWT-Toolbox.gwt.xml

Inside GWT-Toolbox source code, refer to this images like this :

GWT.getModuleBaseURL() + "images/img1.png"

and that's it.

解决方案

Is it the right way of doing it?

Absolutely; this is actually no different from widgets the live in the com.google.gwt.user.User module. (provided inherits means <inherits/>, and putting the GWT-Toolbox JAR in the classpath)

Where do I put my resources files, and how they will be packaged in the GWT-apps ?

You can either put them as simple resources in your JAR so that other modules can use them with ClientBundle by providing their path in @Source.
Or you an put them in a public subfolder (to be exact, the public path of your module, the subfolder name defaults to public but is actually configurable) of your module so they're deployed side-by-side with the *.cache.* compiled files (this is how themes work in GWT).

这篇关于共享GWT模块中的图像资源(小部件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆