You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Barbara Post <ba...@ifrance.com> on 2002/06/20 11:41:04 UTC
Action, MessageResources and Locale
I want my Action to create a MessageResources based on the Locale I choose.
How can it be ?
So that my ActionForm returns errors in the appropriate language...
Thanks.
BP
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Action, MessageResources and Locale
Posted by Slava_L <lo...@esstu.ru>.
Why don't you tried it out ?
If u've i18ned ur bean:messages wut's the problem.
place appropriate "error.something.like.this" accordingly in all of ur
application_XX.properties files
and use this name when creatin' errors i.e for example
ActionErrors errors = new ActionErrors();
if (sometrouble)
errors.add("ErrorName", new
ActionError("error.something.like.this"));
return errors;
----- Original Message -----
From: "Barbara Post" <ba...@ifrance.com>
To: <st...@jakarta.apache.org>
Sent: Thursday, June 20, 2002 6:41 PM
Subject: Action, MessageResources and Locale
> I want my Action to create a MessageResources based on the Locale I
choose.
> How can it be ?
>
> So that my ActionForm returns errors in the appropriate language...
>
> Thanks.
>
> BP
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Action, MessageResources and Locale
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Thu, 20 Jun 2002, Barbara Post wrote:
> Date: Thu, 20 Jun 2002 11:41:04 +0200
> From: Barbara Post <ba...@ifrance.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: struts-user@jakarta.apache.org
> Subject: Action, MessageResources and Locale
>
> I want my Action to create a MessageResources based on the Locale I choose.
> How can it be ?
>
> So that my ActionForm returns errors in the appropriate language...
>
Struts stores the Locale object that was requested by the user in a
session attribute under the symbolic key Action.LOCALE_KEY (the actual
value is "org.apache.struts.action.LOCALE"). Therefore, you can force a
Locale to be used in responses by doing something like this in an Action:
Locale myLocale = ...
session.setAttribute(Action.LOCALE_KEY, myLocale);
before forwarding to the JSP page.
Among other things, this makes it very easy to create a "Select Language"
control if you want to let users switch languages dynamically.
> Thanks.
>
> BP
Craig
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>