marioosh marioosh - 1 year ago 85
Java Question

How to reload resource bundle in web application?

I have resource bundle as Java class that read values from database. When i update db i need to reload bundle, but i don't know how. Anybody helps ?

package model.helpers;
public class Messages_en extends ListResourceBundle {
protected Object[][] getContents() {
// from DB
// ...
}
}


In view i use bundle as below:

<f:loadBundle basename="model.helpers.Messages" var="m" />

Answer Source
ResourceBundle.clearCache();     

OR

Messages_en .clearCache();

Calling this method will reload the resources, it will refresh the bundle