struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Mitchell <>
Subject Re: Using ResourceBundle's subclass in Struts
Date Mon, 14 Jul 2003 15:06:35 GMT
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.

> 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, ""
> 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:

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

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message