Looks good to me.
-- James Mitchell Software Engineer / Struts Evangelist http://www.struts-atlanta.org 770-822-3359 AIM:jmitchtx > -----Original Message----- > From: Seyhan BASMACI (Internet Yazilimlari Yetkilisi) > [mailto:[EMAIL PROTECTED] > Sent: Thursday, August 07, 2003 10:18 AM > To: James Mitchell > Cc: Struts Users Mailing List > Subject: RE: is there any way to load Message Resources from > back-end database instead of properties files? > > > hi James , I am still working on it , but I have a simple question , > beside database based MessageResources, I still want to use > present file based MessageResources feature of struts(in the > case of any problem with my message code), > I am using config parameter to specify which kind of > Message will be created , > if the config parameter is not database , to create > struts message resources I am using > > "MessageResourcesFactory.createFactory().createResources(config) " , > > is that correct???? or enough to do this ? > > > /************ here is code fragment ********/ > > public class TebMessageResourcesFactory extends MessageResourcesFactory > > > public MessageResources createResources(String config) { > > if (config == null || "Database".equalsIgnoreCase(config) ) > > // return own MessageResources class that reads > messages from DATABASE > > return new TebMessageResources(this, config, > this.returnNull); > > else > > // return struts MessageResources class that reads > messages from FILE SYSTEM > > return > MessageResourcesFactory.createFactory().createResources(config); > } > > > > -----Original Message----- > From: James Mitchell [mailto:[EMAIL PROTECTED] > Sent: Wednesday, August 06, 2003 2:12 PM > To: Seyhan BASMACI (Internet Yazilimlari Yetkilisi) > Cc: Struts Users Mailing List > Subject: RE: is there any way to load Message Resources from back-end > database instead of properties files? > > > > we have own tables that holds locations, resources and messages, > > I have a persistent class that gets all data from database. > > I need is a class that extends the class that reads messages > > from properties files, override the method that reads from disk file, > > You need 2 classes minimum. > > public class MyMessageResourcesFactory extends MessageResourcesFactory { > public MessageResources createResources(String config) { > return new MyMessageResources(this, config, this.returnNull); > } > } > > public class MyMessageResources extends MessageResources > implements Serializable { > public MyMessageResources(MessageResourcesFactory factory, String > config) { > this(factory, config, false); > } > public MyMessageResources(MessageResourcesFactory factory, String > config, boolean returnNull) { > super(factory, config, returnNull); > } > > public String getMessage(Locale locale, String key) { > //call your DAO here > } > } > > You would tell Struts to use your implementation by configuring it in the > struts-config: > > <message-resources > factory="com.company.project.whatever.MyMessageResourcesFactory" > parameter="{whatever you put here is passed to the > factory as 'config'}"> > </message-resources> > > > My hack for supporting multiple keys and Modules was to use the > parameter to > designate alternate keys and/or modules. > > Let me know if that helps you. > > > -- > James Mitchell > Software Engineer / Struts Evangelist > http://www.struts-atlanta.org > 770-822-3359 > AIM:jmitchtx > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]