使用@sprite从外部CSS文件附加ImageResource

使用@sprite从外部CSS文件附加ImageResource,css,gwt,sprite,cssresource,clientbundle,Css,Gwt,Sprite,Cssresource,Clientbundle,我试图在GWT2.2项目中同时使用CssResource和ImageResource CssResource和模糊处理工作正常,但我在访问图像时遇到问题 我已经可以通过ImageResource通过以下方式直接从ui.xml文件访问图像: <ui:with type="com.example.client.resource.ResourceBundle" field="myResource"/> <g:Image resource="{myResource.image}"/&g

我试图在GWT2.2项目中同时使用CssResource和ImageResource

CssResource和模糊处理工作正常,但我在访问图像时遇到问题

我已经可以通过ImageResource通过以下方式直接从ui.xml文件访问图像:

<ui:with type="com.example.client.resource.ResourceBundle" field="myResource"/>
<g:Image resource="{myResource.image}"/>
当我将精灵添加到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

您可以从UiBinder模板访问样式,如下所示:

<ui:with type="com.example.client.resource.ResourceBundle" field="myResource"/>

<g:FlowPanel styleName="{myResource.myCssResource.className}"/>


您是否从ClientBundle以外的任何地方引用了
mystyle.css
?在
MyView.ui.xml
中是否有
引用?是的,我从ClientBundle和UiBinder中引用了mystyle.css。我有以下参考资料:
我是否也需要从其他地方参考它?是的,我已经从我的
UiBinder
访问了
ImageResource
,方式与您在这里显示的方式相同。但是我现在不能做的是从外部.css文件访问ImageResource,如Background images/Sprites一节所示。您能在问题中发布
MyView.ui.xml
的内容吗?我会告诉你怎么解决的正如我在原始问题中写的,我可以通过以下方式从MyView.ui.xml访问
ImageResource
并且从CssResource分配样式类名也没有问题:
当尝试使用@sprite符号在文件
mystyle.css
中设置
背景图像
属性时,会出现问题。您需要要通过UiBinder模板对ClientBundle的引用来访问CssResource,如果您使用
加载CSS文件,它将不起作用。因此,您将使用
而不是
。请注意,
@sprite
中工作正常,因为UiBinder只是从中生成一个隐式
客户端包
CssResource
。向隐式
ClientBundle
(错误消息中的
*\u GenBundle
)添加
ImageResource
的方法是在
ui.xml
中使用
。还有
来生成
数据资源。
<ui:with type="com.example.client.resource.ResourceBundle" field="myResource"/>

<g:FlowPanel styleName="{myResource.myCssResource.className}"/>