gwt css uibinder共享资源

hba*_*hba 3 css gwt uibinder

我已经定义了一个ClientBundle,一个Style接口,并通过@source注释将其与我的css文件连接起来.

我有两个问题:

  1. 当我<ui:with>在我的uibinder文件中使用时,我得到以下异常:Deferred binding result type MyStyle should not be abstract. 有人可以解释发生了什么吗?以及如何在我的uibinder文件中正确包含样式?

  2. 我想在许多uibinder上分享资源,而不必每次都支付初始化样式的惩罚.Gwt的贫血开发指南,建议使用UiField(provided=true)或使用@uiFactory.虽然我已成功使用@uiFactory来使用我自己的自定义小部件.我不知道如何使用@uiFactory将样式注入uiBinder.

例如:

//in pojo
@UiFactory
public MyStyle getMyStyle() {
    return myStyle;
}

//in uibinder
<g:Label addStyleNames="{myStyle.defaultLable}"/>
Run Code Online (Sandbox Code Playgroud)

我怎么能得到这个工作?

提前致谢.

Hil*_*amp 7

我在uibinder文件中使用以下构造:

<ui:with field='res' type="com.example.client.resources.MyResource" />
Run Code Online (Sandbox Code Playgroud)

MyResource包含css资源的接口在哪里:

public interface MyResource extends ClientBundle {
  @Source("mycss.css")
  MyCssResource css();
}
Run Code Online (Sandbox Code Playgroud)

MyCssResource是:

public interface MyCssResource extends CssResource {
    String someStyle();
}
Run Code Online (Sandbox Code Playgroud)

在uibinder文件中,使用如下:

<g:TextBox addStyleNames="{res.css.someStyle}" />
Run Code Online (Sandbox Code Playgroud)