You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Nicolas De Loof <ni...@cgey.com> on 2003/04/02 09:13:28 UTC
[RePosted] localize messages in JSP without session
On logon.jsp I would like messages to be localized. AFAIK to do this with Struts I have to put this tags :
<html:html locale="true">
<bean:message key="logon.welcome" />
...
</html:html>
This tags use a Locale objet stored in session scope. My boss doesn't want this logon JSP to create a new session to
limit memory usage. Is they're a way to use Struts i18n with a REQUEST scoped Locale or something like this ?
Do you thing it could be an interseting enhancement for future versions ?
Nico.
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: [RePosted] localize messages in JSP without session
Posted by Nicolas De Loof <ni...@cgey.com>.
I made a text search on RC1 sources for "Locale" :
30 classes use it,
For using "localized" JSP without session, only this changes shoul be needed :
RequestUtils.retrieveUserLocale() :
use
pageContext.getAttribute(locale); // all scopes
instead of
pageContext.getAttribute(locale, PageContext.SESSION_SCOPE);
HtmlTag.currentLocale() :
use
pageContext.getAttribute(Globals.LOCALE_KEY); // all scopes
instead of
session.getAttribute(Globals.LOCALE_KEY);
validator/Ressources.getLocale()
use
locale = (Locale) request.getAttribute(Globals.LOCALE_KEY);
if (locale == null)
locale = (Locale) request.getSession().getAttribute(Globals.LOCALE_KEY);
instead of
request.getSession().getAttribute(Globals.LOCALE_KEY);
I will post a bugzilla ticket for a post 1.1 enhancement.
Nico.
> You could probably override the processLocale() method in RequestProcessor
> to store it in the request scope, but Im not sure what would be involved
> over on the rendering side to get the tags to look for current locale there.
>
> If using locales does indeed require use of the session, than an enhancement
> for an option to allow this to be done using only the request is a good
> idea. This could be quite useful for higher throughput websites that dont
> need to track sessions - though it may involve a bit more effort from the
> garbage collector to clean up throwaway locale objects.
>
> -----Original Message-----
> From: Nicolas De Loof [mailto:nicolas.deloof@cgey.com]
> Sent: Wednesday, 2 April 2003 15:13
> To: Struts Users Mailing List
> Subject: [RePosted] localize messages in JSP without session
>
>
>
> On logon.jsp I would like messages to be localized. AFAIK to do this with
> Struts I have to put this tags :
>
> <html:html locale="true">
> <bean:message key="logon.welcome" />
> ...
> </html:html>
>
> This tags use a Locale objet stored in session scope. My boss doesn't want
> this logon JSP to create a new session to
> limit memory usage. Is they're a way to use Struts i18n with a REQUEST
> scoped Locale or something like this ?
>
> Do you thing it could be an interseting enhancement for future versions ?
>
> Nico.
>
>
> ---------------------------------------------------------------------
> 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
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: [RePosted] localize messages in JSP without session
Posted by Andrew Hill <an...@gridnode.com>.
You could probably override the processLocale() method in RequestProcessor
to store it in the request scope, but Im not sure what would be involved
over on the rendering side to get the tags to look for current locale there.
If using locales does indeed require use of the session, than an enhancement
for an option to allow this to be done using only the request is a good
idea. This could be quite useful for higher throughput websites that dont
need to track sessions - though it may involve a bit more effort from the
garbage collector to clean up throwaway locale objects.
-----Original Message-----
From: Nicolas De Loof [mailto:nicolas.deloof@cgey.com]
Sent: Wednesday, 2 April 2003 15:13
To: Struts Users Mailing List
Subject: [RePosted] localize messages in JSP without session
On logon.jsp I would like messages to be localized. AFAIK to do this with
Struts I have to put this tags :
<html:html locale="true">
<bean:message key="logon.welcome" />
...
</html:html>
This tags use a Locale objet stored in session scope. My boss doesn't want
this logon JSP to create a new session to
limit memory usage. Is they're a way to use Struts i18n with a REQUEST
scoped Locale or something like this ?
Do you thing it could be an interseting enhancement for future versions ?
Nico.
---------------------------------------------------------------------
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