Change source CSS at runtime when using GWT and ClientBundle

I have a ClientBundle:

public interface Resources extends ClientBundle {

    @Source("styles/styles.css")
    Layout styles();

    @Source("styles/styles2.css")
    Styles styles2();

}

In my UiBinder xml, I use this class as follows:

<ui:with field='resources' type='com.nordea.omega.gwt.client.ui.AppResources' />
...
<div class="{resources.styles.label}">Text</div>

The standard is using styles.css, but is it possible to use styles2.css when used at runtime?

+3
source share
2 answers

If you use annotations in the GWT style, AFAIK it will not be possible to dynamically change this value, because annotations / classes are resolved statically, i.e. when the GWT compiles (the last time I used GWT was about a year or so).

A better way would be to move the DOM and change the associated style.css style to another stylesheet. Check out the showc src example for an example of how to do this:

http://code.google.com/p/google-web-toolkit/source/browse/branches/crawlability/samples/showcase/src/com/google/gwt/sample/showcase/client/Showcase.java?r=5652#514

+1

All Articles