struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Timo Tjäder" <>
Subject How to use MessageResources effectively?
Date Thu, 18 Mar 2004 19:50:07 GMT

I have a Bean that my form uses directly to display a 
HTML control <html:select>. This requires localizied
access to the message bundle. Currenty I do not have
user session available in this Bean and i get the
handle to the message resources as follows.

this.resources =    MessageResources.getMessageResources("ApplicationMessageResources");

Everything works just fine, but what makes me worry is that
the debug log seems to download the whole bundle. Is there a more 
clever  way to solve this problem (just switch to another
language bundle), without reading the MessageResource again.

Any good ideas or solutions are wery welcome. However, it seems
that only this way the user language was really changed.



<short pseudo code of the bean>
public Collection getBeanDiscTypeCollection() {
	String myL = getMyLocale().getLanguage();
	String myC = getMyLocale().getCountry();
	Locale l = new Locale(myL,myC);
	if (beanDiscTypeCollection == null) {
	   if (this.resources == null) {
	      this.resources =
	    Vector entries = new Vector(maxDiscTypes + 1);
	    for (int i = 0; i <= maxDiscTypes; i++) {
         	codeLabel =
			resources.getMessage(l,"" + i);
			entries.add(new LabelValueBean(codeLabel, "" + i));
		beanDiscTypeCollection = entries;
         return (beanDiscTypeCollection);

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message