File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Message Bundles Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Message Bundles" Watch "Message Bundles" New topic

Message Bundles

R Ben Parsons

Joined: Aug 05, 2008
Posts: 9
Hi all,

Is there a way to externalize message bundles so that a change to a value doesn't mean re-deploying the WAR or re-starting the application server? Maybe some sort of dynamic HTTP include approach?



R. Ben Parsons<br />SCJA
Darryl Nortje
Ranch Hand

Joined: Jun 11, 2002
Posts: 140
Hello R,

As opposed to externalizing the message bundle, what I have done in the past is put a FileWatchDog on it, monitoring it for any changes. Admitidly I haven't doen this for JSF, so don't know how you would tell JSF about it. But it should be possible. I'll check it out and let you know.
Darryl Nortje
Ranch Hand

Joined: Jun 11, 2002
Posts: 140
This is not as easy as it might seem....

<f:loadBundle uses ResourceBundle to load the bundle. This is turn uses a cache. So each time you get to the page where you are referencing your resource bundle, you are in fact asking ResourceBundle to give you a new Bundle. ie

But, Resource bundle get the original properties file off its cache. There doesn't seem to be a workaround for this. I found a post that mentioned to access the cache and clear through reflection, and tried it but that didn't work for me. Maybe, with whatever you're doing, it works for you.

Hope this helps.

I agree. Here's the link:
subject: Message Bundles
It's not a secret anymore!