2

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?

Benjamin Brandmeier
  • 724
  • 1
  • 9
  • 19

1 Answers1

0

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();
    }
}
helpermethod
  • 59,493
  • 71
  • 188
  • 276
  • 2
    Yes you are right, I didn't mention that in the description of the problem. But I have found the problem causing the error: The package the ResourceBundle class belongs to was not under *de.main.client* which is specified in the *###.gwt.xml* file How trivial ;) – Benjamin Brandmeier Jun 22 '11 at 15:39