Troubles with CSS defined in CssResource

时光总嘲笑我的痴心妄想 提交于 2020-01-02 00:37:48

问题


I am having some problem displaying the CSS using UiBinder and CssResource:

public interface Resources extends ClientBundle {

    @NotStrict
    @Source("style.css")
    Style style();

    @Source("logo.png")
    ImageResource logo();
}

public interface Style extends CssResource {
    @ClassName("orange")
    public String orange();
}

If I apply the CSS like this with UiBinder:

styleName="{res.style.orange}" 

It doen't work, although the CSS ".orange" rule here is fully tested to be rendered properly.

I have defined the resouce in the UiBinder like this:

<ui:with field='res' type='com.mygwtapp.client.Resources'/>

And if I place this for example:

<g:Image resource='{res.logo}'/>

It works, the logo image is displayed but the CSS won't work. Is there any other procedure or method that I have missed that is causing the CSS not to be rendered?


回答1:


You have to call ensureInjected() on your CssResources.

UiBinder does it automatically for a ui:style, but not for CssResources you provide via an ui:with.



来源:https://stackoverflow.com/questions/10262089/troubles-with-css-defined-in-cssresource

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!