【发布时间】:2011-04-05 03:13:06
【问题描述】:
我正在尝试在 GWT2.2 项目中同时使用 CssResource 和 ImageResource。
CssResource 和混淆工作正常,但我在访问图像时遇到问题。
我已经可以通过 ImageResource 直接从 ui.xml 文件中访问图像,方法如下:
<ui:with type="com.example.client.resource.ResourceBundle" field="myResource"/>
<g:Image resource="{myResource.image}"/>
但我无法使用 @sprite 从外部 .css 文件中附加 ImageResource。
我有以下接口:
public interface ResourceBundle extends ClientBundle {
ResourceBundle INSTANCE = GWT.create (ResourceBundle.class);
@Source("com/example/client/resource/images/image.png")
ImageResource image();
@Source("com/example/client/resource/css/mystyle.css")
MyCssResource myCssResource();
}
public interface MyCssResource extends CssResource {
String className();
}
当我将精灵添加到 css 文件中时,
@sprite .className {
gwt-image: 'image';
}
我收到以下错误消息:
[ERROR] - Unable to find ImageResource method value("image") in
com.example.client.views.MyView_BinderImpl_GenBundle : Could not find
no-arg method named image in type com.example.views.MyView_BinderImpl_GenBundle
【问题讨论】:
-
您是否在 ClientBundle 以外的任何地方引用
mystyle.css?MyView.ui.xml中有<ui:style>参考吗? -
是的,我从 ClientBundle 和 UiBinder 都引用了 mystyle.css。我有以下参考:
<ui:style src="../resource/css/mystyle.css" />我还需要从其他地方参考吗?
标签: css gwt sprite cssresource clientbundle