Thank you. This is something I havent gotten to yet (trying to talk the client ouf ot if given the time contraints, of course) but thank you. I will no doubt make use of it!!
On 4/14/05, David Johnson <[EMAIL PROTECTED]> wrote: > ---------- Forwarded message ---------- > From: Fogleson, Allen <[EMAIL PROTECTED]> > Date: Apr 13, 2005 9:18 PM > Subject: RE: Error Messages from the Database - Simple method? > To: [EMAIL PROTECTED] > > David, > > I think I replied to this, but I released a more generalized version of > the two reloadable message resources on sourceforge. (struts apps) > > The main improvements here are ease of development of new types of > message resources. (I have not moved this over to commons-resources as > the superclasses yet by the way so it is workable with struts 1.2x) > Mainly now, to implement a reloadable message resource you subclass my > BaseReloadableMessageResource and supply 2 methods > > 1) parseConfig(...) which will know what to do with the config passed > from the factory. > 2) getMessagesAsProperties() which returns a properties file containing > all the messages for a particular locale. > > This would make it rather simple for you to partition messages between a > DB and a properties file and you can enforce whatever ordering you > desire. (i.e. all general messages come from the DB which can be changed > by admins or whatever, and error messages come from a properties file so > that the replacement arguments aren't mucked up) or vice versa or > whatever. All of the caching/reloading, is determined by a timeout that > can either be hardcoded and supplied to the superclass, or can be a part > of the configuration. To load from different sources would be relatively > simple, you devise some type of configuration that you can parse. > > And then load the messages from the appropriate resource type > (file,db,etc) based on your scheme. > > You can grab the source or binary from the sourceforge site at: > > http://sourceforge.net/projects/struts/ > > The files are in reloadable message resources. > > Al > > -----Original Message----- > From: David Johnson [mailto:[EMAIL PROTECTED] > Sent: Thursday, April 07, 2005 3:13 PM > To: Fogleson, Allen > Subject: Re: Error Messages from the Database - Simple method? > > ahh so inside your factory is where you're connecting to your database > for the sole purpose of populating the messages hashmap? > > I suppose you looked at the default implementation to see that > variable you're meant to be populating, huh? > > I also notice that this is an all or none thing... meaning errors AND > messages in general now have to be in the DB (if I go this route) > > Thank you so much for the assistance. :) > > On Apr 7, 2005 4:06 PM, Fogleson, Allen <[EMAIL PROTECTED]> > wrote: > > David, > > > > Correct, although I believe you can extend o.a.s.u.PropertyResources > for > > an easier implementation. > > > > Once you have your stuff created you get struts to recognize it by > > changing the <message-resources> elements in your struts-config file. > > > > For instance I created a DBMessageResources class and factory (I can > > send them to you if you want a quick example of how to do these > things. > > They don't merge two files but it might give you an idea on where to > go) > > At any rate in mine I expect to get three things from the MR config 1) > > the JNDI Datasource name, 2) the sql to use to retrieve the value > given > > a key, 3) a timeout for my cache. So my message-resources looks like > > this": > > > > <message-resources > > > > > factory="org.homedns.afogleson.messageresources.DBMessageResourcesFactor > > y" > > parameter="java:comp/env/jdbc/myusersDS,SELECT value from > Messages > > where locale=? and messagekey=?,300000" > > null="false" /> > > > > As you can see there is no need to have your classes exist in > o.a.s.util > > or any particular package in fact. > > > > Im sure you are aware, but the parameter is what gets passed as the > > config so it can pretty much be anything you want as long as it can be > > passed as a string. > > > > Let me know if you want my example and I will shoot it your way. > > > > Al > > > > -----Original Message----- > > From: David Johnson [mailto:[EMAIL PROTECTED] > > Sent: Thursday, April 07, 2005 1:47 PM > > To: Fogleson, Allen; Struts Users Mailing List > > Subject: Re: Error Messages from the Database - Simple method? > > > > Oy. > > > > I'm assuming that you're talking about the loadLocale() method > within... > > > > org.apache.struts.util.PropertyMessageResources > > > > I see that inheritance wise, > > > > 1. PropertyMessageResources extends MessageResources > > 2. PropertyMessageResourcesFactory extends MessageResourcesFactory > > > > Logical. > > > > So, I'll create > > > > 1. DatabaseMessageResources extends MessageResources > > 2. DatabaseMessageResourcesFactory extends MessageResourcesFactory > > > > Questions > > 1. should I create them in the org.apache.struts.util. package? > > mucking with struts seems risky > > 2. how do I tell the application to use MY > > DatabaseMessageResourcesFactory and DatabaseMessageResources > > instead of PropertyMessageResourcesFactory and > > PropertyMessageResources > > > > What about my idea of just letting the whole thing run notmally then > > replacing the resulting collection with a NEW collection... The > > benefit there is I dont have to touch Struts at all, which, I'll be > > honest.. I REALLY dont want to. > > > > what I guess I'm looking at is somehow replacing that hashpamp of > > messages.... with my OWN messages..... > > > > whaddya think? > > > > -- > -Dave > [EMAIL PROTECTED] > > -- > -Dave > [EMAIL PROTECTED] > -- -Dave [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]