--- James Mitchell <[EMAIL PROTECTED]> wrote: > On Monday 14 July 2003 03:26, Duan Qiang wrote: > > Hi, > > > > I posted a question but seems nobody replied. > > That usually indicated a lack of "interest", not a lack of "concern". > > > Anyone tried to define a > > subclass of ResourceBundle and use it in Struts? > > None that I'm aware of. There are several reasons for Craig's decision > not to > use ResourceBundle for application messaging when he originally wrote > Struts. > For more details on that decision, search the archives.
The only reason I can remember is that ResourceBundle is frustratingly not Serializable, making it unsuitable for webapp message passing. David > > > > > For a standalone program, it's straightforward to use sel-defined > > resourcebundle classes, for example, > > > > public class MyResourceBundle extends ResourceBundle > > { > > public Object handleGetObject() > > ... > > public Enumeration getKeys() > > } > > > > //use the subclass > > ResourceBundle bundle = ResourceBundle.getBundle("MyResourceBundle"); > > > > However, when I specify the resource name as "MyResourceBundle", > Struts can > > not find the message bundle although my class MyResourceBundle is on > > classpath. > > > > It's possible to replace <bean:message> tag using my own methods, > however, > > the action controller I uses is an instance of DispatchAction, which > will > > match a method name with the message bundle key, for example, > "button.next" > > matches to the function "doNext" and so on. > > > > So I can could totally avoid using struts message functionaliity, or > how I > > can use my own ResourceBundle? > > Writing your own extension of MessageResource is very simple. Checkout > these > 4 classes to see how its done: > org.apache.struts.util.MessageResourcesFactory.java > org.apache.struts.util.MessageResources.java > org.apache.struts.util.PropertyMessageResourcesFactory.java > org.apache.struts.util.PropertyMessageResources.java > > Although, keep in mind that we will be deprecating this api and using > "Resources" from Commons (it is currently in the sandbox, but will be > released soon I'm sure) > > > > > THx, > > > > Regards, > > > > dq > > > > -- > James Mitchell > Software Developer/Struts Evangelist > http://www.struts-atlanta.org > 678-910-8017 > AIM:jmitchtx > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]