Thursday, December 17, 2009

Reusing Resource Bundles from Different Projects in ADF 11g

I got a question from blog reader about how to reuse Resource Bundles from different ADF BC projects. Actually its quite common requirement, when we were starting with JDeveloper 11g Tech Preview 3 we also wanted to reuse Resource Bundles, however it wasn't working. But good news, it works now perfectly.

Download sample application -, it contains two ADF BC projects (one project shares Resource Bundle with labels and another consumes it).

Here is the answer to my reader - in order to access Resource Bundle that doesn't reside within the current project package structure (Model project in this case):

You need to open Project Properties window for Model project, go to Resource Bundle section and there select second tab - Bundle Search. Press plus sign for Bundle List and choose ModelCommon project, its where your Resource Bundle resides:

Resource Bundle will be included into Bundle List:

After it will be included, you can go and define Label Text for your Attributes:

While selecting Text Resource, from Resource Bundle choice list select included Bundle:

You will be able to select Text Resource:

On runtime it picks correct label:


Amit said...

What is better of the 2:
1. have multiple resource bundle properties file or
2. have a single resource bundle properties file?

Which of the above will give better performance?

Andrej Baranovskij said...

All depends on number of multiple files and size of single file. Usually we have multiple big property files, but not too many of them


The LaRue Brew said...

OK. I tried to do this but the only way the file in the other project would be displayed in the list was to select Multiple Shared Bundles option on Basic Configuration. That option automatically creates a new resourceBundle file for the current file you are modifying. I don't want all these resource files to get generated. I just want to use the one I created in its project that I created. Is there some other configuration step I am missing?

Andrej Baranovskij said...

Is it reproduced same thing for my sample app on your platform?


Pep said...

Hi Andrejus,
In this example, you use two different bundles from two different models but in the same project in the same application. But what about to use some model bundle from an imported model?? That's what's happening to me. Any idea? Thanks a lot!

Nishi said...

Hi Andrejus,
We have a requirement to access the resource bundle in Model project from a java/ejb class. is there a way i can access it in Model project using java apis

Andrej Baranovskij said...

Yes, you can do that - same as with any other Java project/technology - same API's.


Harish said...

Hi Andrejus,

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 appreciate.

Thanks and Regards


Anonymous said...

how can i use html anchor tag in resource bundle message.

Anonymous said...

I was wondering if there is a way to package a library and import it inside the Model Project instead of adding it as third project.
I am new in ADF but that was the kind of thing I was expecting, however it has been a challenge.

Michal said...

Is it possible to use multiple resource bundle properties files within, let's say a Model? I would like to use one property file for each package due to big amount of files in each package