Bits of code related to Oracle's Application Development Framework (ADF). Some of the posts in this blog may seem elementary. They are. Nevertheless, you will be amazed to find out how many beginner ADF practitioners are struggling with basic concepts and sample code. Hopefully they will find some here.
Tuesday, April 6, 2010
Bit #5 - Accessing a resource bundle from a backing bean
You can access a resource bundle from a backing by calling the getResourceBundle() method on a javax.faces.application.Application object and specifying the bundle name. You get the Application object by calling getApplication() on the FacesContext. The getResourceBundle() returns a ResourceBundle object. To get some resource data from the bundle, call getString() on the ResourceBundle specifying the resource identifier. The example below illustrates the case.
FacesContext fc = FacesContext.getCurrentInstance(); ResourceBundle bundle = fc.getApplication().getResourceBundle(fc,"bundle_name"); bundle.getString("resource_identifier");