You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Carl-Eric Menzel <cm...@bitforce.com> on 2003/09/16 17:21:48 UTC

Getting Messages in an Action?

Hello,

is it possible to retrieve a message from the application resources
(like <bean:message key="..."/>) inside an Action? How can I get to
the current localized messages?

Thanks
Carl-Eric


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re[2]: Getting Messages in an Action?

Posted by Carl-Eric Menzel <cm...@bitforce.com>.
> MessageResources resources = getResources(request);
> java.util.Locale locale = getLocale(request);
> String yourString = resources.getMessage(locale, "yourString");

Duh. I should read the docs more carefully (and sleep more, probably).
Thank you!

Carl-Eric


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Getting Messages in an Action?

Posted by Andrew Kuzmin <ku...@soft-ukraine.com>.
MessageResources resources = getResources(request);
java.util.Locale locale = getLocale(request);
String yourString = resources.getMessage(locale, "yourString");

--
Andrew Kuzmin
http://www.java201.com


----- Original Message ----- 
From: "Carl-Eric Menzel" <cm...@bitforce.com>
To: <st...@jakarta.apache.org>
Sent: Tuesday, September 16, 2003 6:21 PM
Subject: Getting Messages in an Action?


> 
> Hello,
> 
> is it possible to retrieve a message from the application resources
> (like <bean:message key="..."/>) inside an Action? How can I get to
> the current localized messages?
> 
> Thanks
> Carl-Eric
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Getting Messages in an Action?

Posted by Andrew Hill <an...@gridnode.com>.
Yes, you can call the getResources() method inside your action which will
return a MessageResources object that you can read the localised messages
from. Check the javadoc for details on the parameters.

-----Original Message-----
From: Carl-Eric Menzel [mailto:cm-strutsuserlist@bitforce.com]
Sent: Tuesday, 16 September 2003 23:22
To: struts-user@jakarta.apache.org
Subject: Getting Messages in an Action?



Hello,

is it possible to retrieve a message from the application resources
(like <bean:message key="..."/>) inside an Action? How can I get to
the current localized messages?

Thanks
Carl-Eric


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org