struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Manish Kumar Wadhwa <>
Subject RE: Resource Bundle per session
Date Tue, 18 Nov 2008 04:29:36 GMT
Hi Peter,

I also have same kind of requirement and facing issues in this area.

Can you please send me your code for custom AnnotationValidationInterceptor and related files.

Also will it be a optimized way to override the getText method for initializing our resource
bundle? I tried to use my custom TextProvider for this purpose, but struts 2.0 has some issues
in this area. It is fixed in struts2.1 but it's a beta version, so can't go with that. Can
we do this by creating another custom interceptor?


-----Original Message-----
From: Peter Butler []
Sent: Monday, November 17, 2008 9:23 PM
To: Struts Users Mailing List
Subject: RE: Resource Bundle per session

I've implemented something like this using Struts 2.0.12, although it
was quite a bit of work to get running.

I implemented a database-backed TextProvider (DatabaseTextProvider)
which reads resources from the database instead of from resource
bundles. It caches the text so as not to load the database too heavily.
In the getText() methods I use ActionContext.getContext().getSession()
to get the current session, then use session attributes to figure out
which text to display for the current user. Our application is used by
several different companies so we need to customise the text based on
which company the user is logged into.

I then created an extension of ActionSupport which overrides all the
getText() methods, delegating to DatabaseTextProvider which is injected
using Spring. This means that text supplied by DatabaseTextProvider is
available in actions and JSPs, and will be used by any struts tags.

This worked OK but Struts does not make it easy to override TextProvider
in the validation interceptor. To get this working I had to extend
DelegatingValidatorContext, AnnotationActionValidatorManager and use
them in a custom AnnotationValidationInterceptor and configure the
interceptor stack to use this instead of the default validation
interceptor. A bit of a kludge (and some copy-and-pasted code) but it
works OK. If you don't need to customise validation text then you won't
need to do this.

Hope this helps.


-----Original Message-----
From: Ramez Hassan []
Sent: 17 November 2008 10:02
To: 'Struts Users Mailing List'
Subject: RE: Resource Bundle per session

Thanx for the prompt Nuwan. However, this will cause overlapping in
different resource bundles. As LocalizedTextUtils store the default
list in a static map in static member variable.

-----Original Message-----
From: Nuwan Chandrasoma []
Sent: Sunday, November 16, 2008 5:32 PM
To: Struts Users Mailing List
Subject: Re: Resource Bundle per session


Instead of this ServletContextListener  you can  have a
 HttpSessionListener, just a suggestion, i haven't tried it.

Nuwan C.

Ramez Hassan wrote:
> Dear All,
> Are there any configuration or mechanism for struts 2 to load resource
> bundle for localized messages per user session?
> In other words I need to display localized messages for users based on
> profile and role, but struts 2 loads messages either by request which
> development and not recommended for production.
> Regards,
> Ramez Hassan

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

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

The information contained in this e-mail is confidential and may be privileged. It is intended
for the addressee only. If you are not the intended recipient, please delete this e-mail immediately.
The contents of this e-mail must not be disclosed or copied without the sender's consent.
The statements and opinions expressed in this message are those of the author and do not necessarily
reflect those of the company. The company does not take any responsibility for the views of
the author.

Registered Office: IT-Freedom Limited, 9 Minster Court, Tuscam Way, Camberley, Surrey GU15
Registered in England, Number: 04500346

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


This email and any files transmitted with it are confidential and are solely for the use of
the individual or entity to which it is addressed. Any use, distribution, copying or disclosure
by any other person is strictly prohibited. If you receive this transmission in error, please
notify the sender by reply email and then destroy the message. Opinions, conclusions and other
information in this message that do not relate to official business of the company shall be
understood to be neither given nor endorsed by NIIT Ltd. Any information contained in this
email, when addressed to Clients is subject to the terms and conditions in governing client

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

View raw message