Class ResourceBundleHandler

java.lang.Object
org.imixs.workflow.faces.util.ResourceBundleHandler

@Named @RequestScoped public class ResourceBundleHandler extends Object
The ResourceBundleHandler provides helper method to lookup a label in different bundles. This simplifies the front end implementation as the client does not have to know the bundle a specific resource is located:

<h1>#{resourceBundleHandler.findMessage('application_title')}</h1>

The ResourceBundleHandler load the bundles based on the current user locale.

Resource bundle instances created by the getBundle factory methods are cached by default, and the factory methods return the same resource bundle instance multiple times if it has been cached. For that reason a RequestScoped bean is used here.

The class searches for the resource bundles named 'bundle.messages', 'bundle.app' and 'bundle.custom'. You can overwrite the bundle names with the imixs property value 'resourcebundle.names'. The later entries have a higher priority in case a key is stored in multiple bundles.

Version:
1.0
Author:
rsoika
  • Constructor Details

    • ResourceBundleHandler

      public ResourceBundleHandler()
  • Method Details

    • init

      @PostConstruct public void init()
      This method finds the browser locale
    • getBrowserLocale

      public Locale getBrowserLocale()
    • getMessagesBundleByName

      public ResourceBundle getMessagesBundleByName(String name)
    • get

      public String get(String key)
      Default getter method
      Parameters:
      key -
      Returns:
    • findMessage

      public String findMessage(String key)
      This helper method findes a message by key searching all bundles.
      Parameters:
      pe -