GWT UiBinder doesn't load the stylesheet

你。 提交于 2019-12-03 17:04:44

Ok, i found the solution.

It turned out to be the not-injected UserPanelCss.

The solution was in UserPanelResources,java:

public interface UserPanelResources extends ClientBundle {
    public final static UserPanelResources INSTANCE = GWT.create(UserPanelResources.class)

    public interface UserPanelCss extends CssResource {
        String main();
    }

    @Source("css/userpanel.css")
    UserPanelCss userpanel();
}

And in the UserPanel.java class just add:

static {
    UserPanelResources.INSTANCE.userpanel().ensureInjected();  
}

I had the same problem for a CSS resource that I was only using in my UiBinder file.

I added a hack to my widget constructor to fix it. Here's the equivalent using the above class names:

  @Inject
  UserPanel(UserPanelResources resources) {
    resources.userpanel().ensureInjected();
    initWidget(BINDER.createAndBindUi(this));
    ...
  }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!