On 4/24/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
I've encountered a rather annoying issue. To select the language in which our
labels should be displayed, we use fmt:setLocale. Everything works fine,
everybody's happy.
But. To validate our forms, we use DynaValidator. In our webapp, we have 1 form
which has only 1 field. When validation fails, the browser redisplays the form, with
an appropriate error message. The problem is that we show our error message with
<html:errors /> and since struts doesn't know the locale which was set with
fmt:setLocale, this message is retrieved from the resource bundle of the standard
browser language.
Struts uses either the Locale stored under a key in the Session
(default key is Globals.LOCALE_KEY, but you can specify an alternate
on tags like <html:errors/>) or if thats not present the default
locale for the request. So I think you have a number of options:
1) Set the locale in the Session
2) Create a custom TagUtils instance overriding the getUserLocale()
method (Struts 1.3.5 or later since thats when the static
setInstance() method was added to TagUtils).
3) Create your own custom equivalent of the <html:errors/> (or
<html:messages>) tag that access the ActionErrors object created by
the validation process
Niall
Is there anyone who knows how to set the language in a JSP, for that particular
page? It has to be on the page itself, it can't be done in an action or
somewhere else. Or maybe another way to show the error message with
logic:messagesPresent and retrieval of the error message from a resource bundle.
Thanks in advance
Kind regards,
Bjorn De Bakker
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]