Accessing Resource Bundles from a ViewObject

There were couple of threads in ADF BC discussion forums asking for APIs to access associated resource bundle from a ViewObject/EntityObject class. One possibility is to use standard java.util.ResourceBundle API. Another interesting approach is to make use of the oracle.jbo.common.StringManager APIs used by the ADF BC layer. This is a wrapper over standard java ResourceBundle class.

The below method is based on the second approach. This help you to retrieve the value for a key from the resource bundle associated with a ViewObject.

    public String getLocalizedValue(String key) {

        ResourceBundleDef resourceDef = this.getResourceBundleDef();
        Locale locale = this.getApplicationModule().getSession().getLocale();
        String retVal =
            StringManager.getLocalizedStringFromResourceDef(resourceDef, key,
        return retVal;

Where can I see the reference for the 'ResourceBundle' in a ViewObject?

<ResourceBundle> element in the ViewObject's XML definition references the associated resource bundle file.
<ViewObject ....>

You can download the sample workspace from here.
[Runs with Oracle JDeveloper 11g R1 PS2 + HR Schema]

This sample tries to initialize the DepartmentName with a value from the resource bundle that is associated with Department ViewObject. You can see that 'DepartmentsViewRowImpl' java file contains the above mentioned getLocalizedValue(...) method. This method is referred through groovy expression adf.object.getLocalizedValue("DEFULT_DEPT_NAME") specified against DepartmentName in the DepartmentsView.

Learn More ...

There are a lot more points like this. If  you are curious to learn the internals of the ADF Business Components and ADF Binding Layer,  the following book is for you - Oracle ADF Real World Developer’s Guide.
More details about this book can be found in this post-


  1. I have a question. The above approach assumes that the resource bundle is within the jar file which is not usually the case. If I have to change a label value, I will have to redeploy the jar file. Is there a way to specify a properties file that is outside of a jar and I still have control as to where the properties file is located?


  2. Hi Jobinesh,

    Since you are an authority on ADF I was wondering if you could help me resolve my issue.

    Problem Statement:
    1. I have a simple fusion application with Model and view controller.
    2. The model as well as view controller project has one resource bundle each.

    Question 1:
    I would like to customize a resource bundle present in Model/View Controller Project (i.e change a key value with out changing the key value in the original project)value.

    Couple of Ways in which I did this:
    Approach 1:
    Created resource bundles with the same name as present in Model/ViewController and deployed it as a shared library and referred it in the applications weblogic-application.xml

    Problem with the above approach:
    1. I have to maintain a copy of every single key in the shared library even though I need to change only few values:

    Approach 2:
    a)Create a resource bundle with just the values I would like to customize.
    b) Deploy it as a shared library
    c) Write a bean which checks for the key in the shared resource bundle and if it doesnt find it , then look for the same key in the project's resource bundle.

    Cant use this approach to customize resource bundle present in Model project.

    Note: I know it is possible to do achieve some of this using MDS, but I want to stay clear from it.

    So what I am looking at:
    1. Easier way to change label values for both Entity/View(jspx) objects with out changing the base resource bundle.
    2. I would like to avoid the whole redudant key issue which I mentioned earlier and just be able to change the key whose values I would like to change.

    Any help in this regard would be highly appreciated.

    Thanks and Regards


Post a Comment