maandag 23 november 2009

JSF: translation of messages in managed bean

In JSF managed beans you can add messages to the context for use in views. For instance when an error occurs you can add a message to be displayed to the user. This is how:

    new FacesMessage("message"));

The null is an identifier you can provide in order to identify an element of the view. I don't want that kind of information in my managed bean so I left this out. But that isn't the problem. My problem is that the message wasn't translated this way. So I figured out how to get to the resourcebundle configured in the faces-context definition:

ApplicationFactory factory = 
    (ApplicationFactory) FactoryFinder
Application application = factory..getApplication();
ResouceBundle bundle = ResourceBundle.getBundle(

Geen opmerkingen:

Een reactie posten