struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton" <>
Subject Re: help message resources
Date Fri, 18 Jun 2004 22:45:10 GMT
Rather than modifying RequestUtils why not configure Struts to use your own
MessageResources implementation:

1) Extend PropertyMessageResources setting the returnNull property to 'true'
in the constructor and overriding the getMessage() method

public class MyMessageResources extends PropertyMessageResources {

    // N.B. calls parent class constructor with returnNull = true
    public MyPropertyMessageResources(MessageResourcesFactory factory,
String config) {
        super(factory, config, true);

     public String getMessage(Locale locale, String key) {
        String msg = super.getMessage(locale, key);
        return msg == null ? "keynotFound.message" : msg;


2) Create a Factory for your MessageResources implementation

public class MyMessageResourcesFactory extends MessageResourcesFactory {

   public MessageResources createResources(String config) {
        return new MyMessageResources(this, config);

3) Configure Struts to use your MessageResources class. In the

   <message-resources parameter="...."
factory="mypackage.MyMessageResourcesFactory "/>


----- Original Message ----- 
From: <>
To: "struts-user" <>
Sent: Friday, June 18, 2004 10:03 AM
Subject: help message resources

i 'm tring to change the message visualization (i don't want to show the
user a
message like '???foo???') when the key of the message is not present in my
ApplicationResources files. how can i do ?
The only solution i found is to modify the method message(pageContext,
locale, key, args[]) of the RequestUtils class adding at the end the

if(result.startWith("???") && result.endWith("???")){
  result= (resources.getMessage(userLocale,"keynotFound.message");

Is there cleaner way to do this???

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

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

View raw message