CssResource w/o UiBinder

22 views
Skip to first unread message

Lars

unread,
Jul 7, 2011, 1:15:52 PM7/7/11
to google-we...@googlegroups.com
So, I've had success using UiBinder to declare styles in <ui:style> blocks and then accessing them in my .java file via:

interface Styles extends CssResource {
   String hideAdditionalFilters();
   String showAdditionalFilters();
}

Now I have a class that does NOT have an associated UiBinder file and am attempting to access styles in a .css file like the example shown here:
http://code.google.com/webtoolkit/doc/latest/DevGuideClientBundle.html#CssResourceCookbook

So, in my .css file (LinkBox.css) I have:
.TwistyPanel {
    margin-top: 25px;
    background-color: orange;
}

Then in my .java file, I have:
interface LinkBoxCss extends CssResource {
   String TwistyPanel();
}
interface MyResources extends ClientBundle {
    @Source("LinkBox.css")
    LinkBoxCss css();
}
MyResources resources = GWT.create(MyResources.class);

...

VerticalPanel root = new VerticalPanel();
root.addStyleName(resources.css().TwistyPanel());

Now, when I run this in debug mode I can see the obfuscated class name on the <table> tag representing the VerticalPanel. However, the styles associated with .TwistyPanel (i.e. the background color and margin) are not applied... Its as if the obfuscated class name has no rules defined in it at all...

Am I missing something here?  Am I supposed to call "ensureInjected" somewhere? Am I supposed to inherit a module somewhere?

Thanks for your time.

Brian Reilly

unread,
Jul 7, 2011, 2:28:36 PM7/7/11
to google-we...@googlegroups.com
Try adding a call to resources.css.ensureInjected(). I've seen that problem before and I think the call ensureInjected() fixed it.

-- Brian


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/NUGIkufQUkwJ.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Lars

unread,
Jul 7, 2011, 2:55:03 PM7/7/11
to google-we...@googlegroups.com
You are exactly right.

I added "resources.css().ensureInjected();" in the constructor of my class and it all works now.

Much appreciated.

- Lars
Reply all
Reply to author
Forward
0 new messages