ClientBundle

59 views
Skip to first unread message

Tushar Bhasme

unread,
Dec 1, 2014, 3:48:13 AM12/1/14
to gwt-pl...@googlegroups.com
I am trying to use ClientBundle for my app but facing an error. As specified in documentations:
- inherited  Resources in my gwt.xml.
- Extended ClientBundle
- Created style interface by extending CssResources, added accessor methods for all styles.
- Added member for the Style interface and specified its @Source css.
- Added member INSTANCE using GWT.create.
At this point, the moment I compile, I get ERROR: GWT.create() is only usable in client code!  It cannot be called, for example, from server code.  If you are running a unit test, check that your test case extends GWTTestCase and that GWT.create() is not called from within an initializer or constructor.
    at com.google.gwt.core.shared.GWT.createImpl(GWT.java:77)

Did I miss any step?

Thanks,
Tushar

Richard Wallis

unread,
Dec 1, 2014, 3:50:46 AM12/1/14
to gwt-pl...@googlegroups.com
Can you share your gwt.xml file and the fully qualified package name for your resource interface?

--
You received this message because you are subscribed to the Google Groups "GWTP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gwt-platform...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

tushar bhasme

unread,
Dec 1, 2014, 3:55:11 AM12/1/14
to gwt-pl...@googlegroups.com
attached gwt.xml
Resource bundle package: com.abc.applications.client.resources


Thanks,
Tushar Bhasme

--
You received this message because you are subscribed to a topic in the Google Groups "GWTP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gwt-platform/vY1vGoGjrSk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gwt-platform...@googlegroups.com.
Trust.gwt.xml

Richard Wallis

unread,
Dec 1, 2014, 3:58:11 AM12/1/14
to gwt-pl...@googlegroups.com
Ok and Trust.gwt.xml is in com.abc.applications?

tushar bhasme

unread,
Dec 1, 2014, 4:00:57 AM12/1/14
to gwt-pl...@googlegroups.com
Yes.
Oh, and I am calling INSTANCE.style().ensureInjected() from ClientModule configure(). Can that be a problem?


Thanks,
Tushar Bhasme

Richard Wallis

unread,
Dec 1, 2014, 4:04:34 AM12/1/14
to gwt-pl...@googlegroups.com
Yes that's the problem you shouldn't be putting runtime code in your gin modules.  Put that code in your bootstrapper instead.

GinModules are executed at compile time so it's not valid to ensure a script is injected into the page because there is no page at compile time.

tushar bhasme

unread,
Dec 1, 2014, 4:11:26 AM12/1/14
to gwt-pl...@googlegroups.com
By bootstrapper, you mean the home page?


Thanks,
Tushar Bhasme

Richard Wallis

unread,
Dec 1, 2014, 4:13:29 AM12/1/14
to gwt-pl...@googlegroups.com

tushar bhasme

unread,
Dec 1, 2014, 4:16:58 AM12/1/14
to gwt-pl...@googlegroups.com
Ah, ok!
Thanks Richard!


Thanks,
Tushar Bhasme

Christian Goudreau

unread,
Dec 1, 2014, 3:01:37 PM12/1/14
to gwt-pl...@googlegroups.com
A pattern that I like to use in all my apps is to have a Class named RessourceLoader in with I inject all ressources and call ensureInject from there.

That resourcesLoad is bound as an EagerSingleton to ensure it is call when you application instantiates.

Christian Goudreau | CEO - Président

tushar bhasme

unread,
Dec 2, 2014, 1:13:54 AM12/2/14
to gwt-pl...@googlegroups.com
That's a really nice and clean idea.
Thanks for sharing Christian!


Thanks,
Tushar Bhasme

suito

unread,
Jul 26, 2015, 5:20:46 PM7/26/15
to GWTP, tush...@gmail.com
Hello,

I have the same problem with CSS with ClientBundle. What is the correct to do that ?

I tried that in ApplicationView :

    @Inject
   
ApplicationView(Binder uiBinder) {
        initWidget
(uiBinder.createAndBindUi(this));
       
AppResources.INSTANCE.customStyle().ensureInjected();
   
}

but still getting errors. I don't understand what to do in GWTP.

Thank you.


Reply all
Reply to author
Forward
0 new messages