Greg, I implemented this by creating my own ResourceBundle implementation ("DataResourceBundle"). This handles all of the database access and returns the appropriate string to Struts by key when asked.
It is enabled by adding the following constant in struts.xml: <constant name="struts.custom.i18n.resources" value="xxx.utils.content.DataResourceBundle"/> Finally, in the view, you must wrap an i18n tag for the text-based tags to work properly: <@s.i18n name="xxxx.utils.content.DataResourceBundle"> I'm not sure if this is the best way, but it also allows me to control the caching aspect of the bundle, as Struts 2 and even Java will cache a resource bundle on their own. During development, I wanted to be able to reload the language tables easily. Note that for other languages you must make "shell" bundles like DataResourceBundle_fr which simply extends DataResourceBundle and sets the getLocale() method appropriately. Mike -----Original Message----- From: Greg Akins [mailto:angryg...@gmail.com] Sent: Friday, July 16, 2010 7:58 AM To: user@struts.apache.org Subject: Re: Any way to load resources in java.util.ResourceBundle I'm resurrecting this message because I have the same need. I'm converting some code to Struts2, from a JSP/Servlet application. Currently we create bundles from a database, that have keys per customer and language for most of the text in our application. A simple solution to this would be to override LocalizedTextUtil.findDefaultText and add a call to our classes that load the text into a ResourceBundle. However it doesn't look like there is anyway, in Struts 2.1.8.1 to use my own version of LocalizedTextUtil. Does anyone have any thoughts on how I might do this? On Wed, Jan 27, 2010 at 12:43 PM, Bhaarat Sharma <bhaara...@xxxxxxxxx>wrote: > We have seen situations where sometimes the global resource bundles > are lost intermittently for some sessions. We are in a > clustered/shared environment where multiple apps are deployed onto a > GlassFishV2 server. > Multiple apps share the struts2 core jars. > > We have some pages where we have written a custom Resource loader and > everything looks fine on these pages. Problem is on pages that utilize > <s:text name="my.label.name"/>. Our properties files reside globally > in WEB-INF/lib > > Our custom resource loader works as follows in a JSP > > <%CustomMessageResrouce cusResource = new > CustomMessageResource("Resource")%> > <%= cusResource.getMessage("my.label.name")%> > > Java code for it looks like: > import java.util.ResourceBundle; > ResourceBundle resource = ResourceBundle.getBundle(baseName); > > > So we know that loading properties into resourcebundles and using them > as shown above works. > > My question is..can we do the same for struts2. Can we forcefully load > the resourcebundles inside java.util.ResourceBundle and then have them > be used in <s:text> tag? -- Greg Akins http://insomnia-consulting.org http://www.pghcodingdojo.org http://pittjug.dev.java.net http://twitter.com/akinsgre http://www.linkedin.com/in/akinsgre --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org