after running into some problems with the deprecated ways to include css resources into my application I'm eager about using ClientBundle to include the css files.
I added the following line to my ###.gwt.xml file:
<inherits name="com.google.gwt.resources.Resources" />
I created an interface which looks like this:
import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.CssResource;
public interface ResourceBundle extends ClientBundle
{
public static final ResourceBundle INSTANCE = GWT.create(ResourceBundle.class);
@Source("GWT_Chat.css")
public CssResource css();
}
In my onModuleLoad() method I'm calling:
Window.alert(ResourceBundle.INSTANCE.css().getText());
My css file is a random css file without any of the possible gwt additions.
When calling the application in the browser, the error I face is:
[ERROR] [gwt_chat] - Line 33: No source code is available for type de.main.resources.ResourceBundle;
did you forget to inherit a required module?
Is there anything I left out?
Yes, you need to implement a Subtype of CssResource
and return it:
public interface ResourceBundle extends ClientBundle
{
public static final ResourceBundle INSTANCE = GWT.create(ResourceBundle.class);
@Source("GWT_Chat.css")
public MyCssResource css();
public static interface MyCssResource extends CssResource {
String getText();
}
}