PDA

View Full Version : How to set the Theme in onModuleLoad?



obender
9 Jun 2008, 12:11 PM
I'm wondering what is the right way to set the Theme (let say Theme.GRAY) on load of a module. Basically I want my application to use a GRAY theme by default.
It doesn't look like I can just do this:


public void onModuleLoad()
{
GXT.switchTheme( Theme.GRAY );
...
}

obender
9 Jun 2008, 12:36 PM
is this going to be a Ok solution?


public void onModuleLoad()
{
//set theme
if( StateManager.getProvider() == null ) {
StateManager.setProvider( new CookieProvider( null, null, null, false ) );
}
StateManager.set( "theme", Theme.GRAY.asMap() );
//--------------------
...
}

darrellmeyer
9 Jun 2008, 12:53 PM
Try this:


GXT.setDefaultTheme(Theme.GRAY, true);

obender
9 Jun 2008, 1:00 PM
Thanks!

mgrouse
30 Jun 2009, 10:07 AM
Hello:

I have a slightly different problem. First the short version of my question. Is there any way I can call GXT.setTheme() (or some equivalent piece of code) in the 'middle' of my app (two frames open) and accomplish a theme change with OUT having the entire app reload?

Now the long version:
The reload is playing havoc with a static member of a static class that I have as essentially a singleton available to all panels opened by the user. The singleton holds info on the user (names etc.) and is loaded from the DB during onModuleLoad(). When I use GXT.setTheme() after save is pressed on a user prefs panel, the module reloads, which Would be ok, but this singleton does not reload with the recently saved info from the DB, but rather reverts to the version that existed when the user first opened the browser. Its as if some wierd caching is going on.

sven
30 Jun 2009, 10:15 AM
You can write your own "themechanger" that just toogles the css files without any reload.

mgrouse
30 Jun 2009, 10:31 AM
You can write your own "themechanger" that just toogles the css files without any reload.

Hmmm. I'm rather new to CSS and and all that. I've been using GWT and GXT for about 3 months now. I'm not entirely sure about what you are suggesting.

Do you mean editing the DOM via code? Or are you refering to writing my own switchTheme() out of pieces from ThemeManager etc..

Thanks for the fast reply!

hansbrooks
10 Sep 2009, 2:47 PM
Thanks !