如何在GWT ClientBundle? [英] How to ClientBundle in GWT?

查看:212
本文介绍了如何在GWT ClientBundle?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我第一次使用GWT ClientBundle。我写了扩展它的接口,这里是代码:

  package edu.etf.fuzzy.client.login; 

import com.google.gwt.resources.client.ClientBundle;
导入com.google.gwt.resources.client.ImageResource;

public interface资源扩展ClientBundle {

@Source(logo_federacija.jpg)
ImageResource logo();

@Source(shim.gif)
ImageResource shim();
}

我的问题是:如何判断这些资源的确切位置案例)可以找到。我应该把他们:
a)放在与界面相同的目录下 - (难看)?
b)在某些特定的目录中永远无法更改?
c)在我想要的目录中,但是应该有机制来指定它 - (会很棒)?

谢谢。

解决方案

我通常为资源创建一个新的包( com.example.project.resource )和把 ClientBundle 接口和相应的资源放在一起(就像在一个目录中一样) - 它是一个java文件加上一堆图像,不需要进一步分离,恕我直言。

至于资源的路径 - 您可以通过 @Source(path)注释来传递它们。例如,如果您在 com.example.project.resource 中有 ClientBundle 接口,并且 com.example.project.images ,那么你会写 @Source(../ images / shim.gif)。你可以使用绝对路径,但要确保将它们存储在一个静态变量中并在资源中共享,因此可以很容易地重写;)


I am using GWT ClientBundle for the first time. I wrote interface that extends it and here is the code:

package edu.etf.fuzzy.client.login;

import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.ImageResource;

public interface Resources extends ClientBundle {

 @Source("logo_federacija.jpg")
 ImageResource logo();

 @Source("shim.gif")
 ImageResource shim();
}

My question is: How do I tell where exactly these resources (images in this case) can be found. Should I put them: a) in the same directory as interface - (ugly)? b) in some specific directory that never can be changed ? c) in directory that I want, but there should be mechanism to specify it - (would be great)?

Thank you.

解决方案

I usually create a new package for resources (com.example.project.resource) and put the ClientBundle interface and the appropriate resources there (together, as in in one directory) - it's one java file plus a bunch of images, no need for further separation, IMHO.

As for the paths to the resources - you can pass them via @Source("path") annotation. For example, if you have your ClientBundle interface in com.example.project.resource and images in com.example.project.images, then you'd write @Source("../images/shim.gif"). You could probably use absolute paths, but make sure you store them in a static variable and share amongst the resource, so it can be easily overridden ;)

这篇关于如何在GWT ClientBundle?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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