Reputation: 1079
I have a GWT-question,
I am trying to move my css to ClientBundle as CssResource as it claims being the best practice, but there is a problem. It does work with element-ID and element-name but not with class names. So it works when I have
div{
color: red;
}
#whatever_id{
color: black;
}
But if I add a class name with a dot (.) as
div{
color: red;
}
#whatever_id{
color: black;
}
.whatever_classname{
color: green;
}
Then I get following excepssion
onModuleLoad() threw an exception
Exception while loading module com.acatime.edutime.client.edutime. See Development Mode for details.
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:411)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:526)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.ExceptionInInitializerError
at com.acatime.edutime.client.edutime.onModuleLoad(edutime.java:29)
... 9 more
Caused by: java.lang.RuntimeException: Deferred binding failed for 'com.acatime.edutime.client.resources.GeneralResources' (did you forget to inherit a required module?)
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:53)
at com.google.gwt.core.shared.GWT.create(GWT.java:72)
at com.google.gwt.core.client.GWT.create(GWT.java:86)
at com.acatime.edutime.client.resources.GeneralResources.<clinit>(GeneralResources.java:11)
... 10 more
Caused by: com.google.gwt.core.ext.UnableToCompleteException: (see previous log entries)
at com.google.gwt.dev.shell.ModuleSpace.rebind(ModuleSpace.java:610)
at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:470)
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:49)
... 13 more
Any idea what I am missing???
Upvotes: 0
Views: 521
Reputation: 1079
Thank you Andrei and Braj for your answers. I found what I was missing.
The thing I didn't get it from the beginning was that I was adding class name as following:
myWidget.setStyleName("whateverClassname);
And that was obviously the problem. It looks like when you are using CSS through ClientBundle/CssResource then you have to designate the class name as following:
myWidget.setStyleName(MyResources.INSTANCE.myCss().whateverClassname());
And da da, suddenly everything working just fine :) I hope now this is the right way adding style to a GWT app. I'm kind of newbie in GWT and trying to follow the best practices recommended at GWT's website.
Upvotes: 0
Reputation: 41089
There used to be a problem with class names containing underscores. Try class names without underscores.
Upvotes: 1