Friday, October 29, 2010

Re: best practice for handling CSS themes

On Oct 29, 2:03 am, wolfgang <> wrote:
> I was facing the same question and my solution was to have my main
> theme in a CSSResource file.
> This resource file is injected during the loading procedure of the
> app.
> Since the layout of my app is defined through CSS, I only allow to
> change a few things (like color, font-style, various sizes ...).
> For this I use the runtime substitution (@eval) - so I can change
> things during runtime. I only have to (re-)inject the affected
> stylesheet again.
> This works fine so far and I'm not knowing an other way to do this. So
> if there's a better way - please post.
> > GWT helps *me* to not have to worry so much about
> > browsers-that-aren't-Firefox. But what happens when I hand over the
> > WAR (with just HTML, CSS, and JavaScript) to a third party and they
> > want to add their own branding? Do *they* then have to worry about
> > cross-browser issues? Or would I have to limit them to using
> > "portable" CSS only?
> Since I'm using CSSResource there is no way to replace the css file
> without compiling the app again (the css styles may be obfuscated and
> added to the widgets). I hope this is correct.

I haven't tried this, but my guess is you could create a client bundle
with all your goodies inside it. Then extend that client bundle and
override the various style sheet source locations, then you could just
selectively inject the client bundle into your application.

interface BaseClientBundle extends ClientBundle{

SomeCssResource getCssResource();

interface ExtendedClientBundle extends BaseClientBundle{
SomeCssResource getCssResource();

You may need to reload the page to make sure that the yellowTheme.css
doesn't get some funky behavior from greenTheme, but this should allow
you to swap out skins on the page.

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment