I am currently in the process of updating some older code to GWT 2 and encountering some strange behavior. I have a custom interface that extends ClientBundle, as recommended by the GWT documentation. Within this bundle, I have defined multiple CssResources to link to various .css files for my module. The issue arises when I try to initialize my module. In the initialization code, I retrieve the static reference to each CssResource and call ensureInjected(). However, only the first call seems to take effect. Subsequent calls are being ignored, and the CSS styles are not being applied to the application. How can I properly work with multiple CSS files for a single module?
CssBundle.java
public interface CssBundle extends ClientBundle {
public static final CssBundle INSTANCE = (CssBundle) GWT.create(CssBundle.class);
/* CSS */
@Source("mypath/public/Client.css")
public ClientCss mainCSS();
@Source("mypath/resources/css/mini/ext-all.css")
public ExtAllCss extAllCSS();
}
ClientCss.java
public interface ClientCss extends CssResource {
String applicationTitle();
String branding();
String bugReportDirections();
@ClassName("Caption")
String caption();
}
ExtAllCss.java
public interface ExtAllCss extends CssResource {
@ClassName("close-icon")
String closeIcon();
@ClassName("close-over")
String closeOver();
@ClassName("col-move-bottom")
String colMoveBottom();
}
MyModule.java
public class MyModule extends Composite
{
public void initialize()
{
//the CSS from this resource is applied to the client
CssBundle.INSTANCE.mainCSS().ensureInjected();
//this line does not apply the CSS styling
CssBundle.INSTANCE.extAllCSS().ensureInjected();
}
}