You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by James Mitchell <jm...@telocity.com> on 2002/06/20 05:35:49 UTC

RE: MessageResources

Let's bounce this on the dev list.

Struts gurus, this was in response to someone (I doubt that I'm the only
one) asking about having the resource bundle loaded from xml file(s).

(and yes....I'm well aware of the "thanks for volunteering" approach to
requests for enhancements ;)

Is this ok for pursuing further?
What kind of priority would it be?

Personally, I'd also like to be able to load the resources from a JDBC
source.


Your thoughts?


James Mitchell
Software Engineer\Struts Evangelist
Struts-Atlanta, the "Open Minded Developer Network"
http://struts-atlanta.open-tools.org

> -----Original Message-----
> From: Tero P Paananen [mailto:tpp@viant.com]
> Sent: Wednesday, June 19, 2002 6:07 PM
> To: jmitchtx@telocity.com
> Subject: RE: MessageResources
>
>
> > Would you care to donate the source for the cause?
>
> James,
>
> Got a major deadline over and done with today, so I
> got some time.
>
> Here's how the XMLMessageResources.java will work:
>
> The XML content files follow Interwoven's dcr4.5.dtd
> DTD, which is the default DTD for content exported into
> XML files from Interwoven. The format is as follows:
>
> <record type="content" name="Name for the XML file">
> 	<item name="message.key">
> 		<value>message value</value>
> 	</item>
> 	<!-- multiple items -->
> </record>
>
> The current implementation has four java classes:
>
> XMLMessageResources.java
> XMLMessageResourcesFactory.java
> LocaleXMLFilenameFilter.java
> 	- FilenameFilter that returns a list of XML files
> 	  that contain messages for the given locale
> XMLUtils.java
> 	- the XML parsing routines. Uses Digester to parse
> 	  the XML files into Properties objects
>
>
> XMLMessageResources extends PropertyMessageResources and
> overloads the loadLocale() method to read XML files instead
> of .properties files.
>
> XMLMessageResources will read messages from multiple XML
> files and the messages can be specified in as many XML files
> your operating system will allow you to have. This means
> that you can easily group your messages in logical groups:
> errorMessages.en_US.xml, login.en_US.xml, logout.en_US.xml,
> etc. without having to specify that stuff anywhere in your
> application.
>
> The current implementation reads files from one directory,
> but I'm thinking to change that to read them from locale
> specific directories:
>
> 	/WEB-INF/messages/en_US/errorMessages.xml
> 	                        login.xml
> 	/WEB-INF/messages/en/errorMessages.xml
> 	                     login.xml
>
> I think that's a better way to organize the files. And it
> would also get rid of some of the sillyness in
> LocaleXMLFilenameFilter.
>
> That's pretty much it.
>
> We also developed on-the-fly message resources reloading
> the Struts framework could use, unless it's already in
> the 1.1 version.
>
> Sound good?
>
> 				-TPP
>
>
> > > -----Original Message-----
> > > From: Tero P Paananen [mailto:tpp@viant.com]
> > > Sent: Monday, June 10, 2002 5:57 PM
> > > To: Struts Users Mailing List; Struts-Atlanta@open-tools.org
> > > Subject: RE: MessageResources
> > >
> > >
> > > > I agree, in fact, I wonder if it can be extended to load from
> > > > other means
> > > > such as xml, rdbms, or call to a url (ftp/http/whatever)
> > >
> > > We implemented XMLMessageResources.java on our current
> > > project.
> > >
> > > Interwoven had problems getting stuff into .properties
> > > files, so we had to read XML files instead.
> > >
> > > The implementation was so remarkably easy that it felt almost
> > > like cheating :)
> > >
> > > 	-TPP <- likes frameworks that make my life easier
> > >
> >
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>