Monday, January 15, 2007

How to give initialisation parameters to a GWT component

GWT init initialisation parameter dynamic config

Where you have a servlet, JSP or other technology dynamically producing the HTML "host page" for a GWT component, it makes sense that you may want to parameterise the way the GWT component renders/behaves based on certain initialisation/input parameters.

How do pass parameters into the Module?

There is a useful Dictionary facility in the Internationalisation (I18N) module ... it doesn't really have anything to do with Internationalisation but it's in this module because you could get the host page to provide key-to-locale-specific-message mappings to save the Module using any hard coded message text in a specific language.

It's generic enough that you could use it for any mapping of values.

The GWT documentation for Dictionary shows how to import the I18N module to your own module and then load the key-value mappings defined in the host page from your GWT code.


Dan Moore said...

Nice find! I just blogged about the way I was doing things, but how this is a better to pull config info from a host page.

nico said...

that's an excellent idea.

Charlie "Atrox" Collins said...

Yes, props for this, I just stumbled on it also and it is a very elegant approach.

Vijay Akkineni said...

Thanks Much