Reading train stop display names from a resource bundle
Posted
by Frank Nimphius
on Oracle Blogs
See other posts from Oracle Blogs
or by Frank Nimphius
Published on Thu, 17 Nov 2011 08:47:31 -0600
Indexed on
2011/11/18
1:56 UTC
Read the original article
Hit count: 342
/Oracle/ADFc
In Oracle JDeveloper 11g R1, you set the display name of a train stop of an ADF bounded task flow train model by using the Oracle JDeveloper Structure Window.
To do so
- Double-click onto the bounded task flow configuration file (XML) located in the Application Navigator so the task flow diagram open
- In the task flow diagram, select the view activity node for which you want to define the display name.
- In the Structure Window., expand the view activity node and then the train-stop node therein
- Add the display name element by using the right-click context menu on the train-stop node, selecting Insert inside train-stop > Display Name
- Edit the Display Name value with the Property Inspector
Following the steps outlined above, you can define static display names – like "PF1" for page fragment 1 shown in the image below - for train stops to show at runtime.
In the following, I explain how you can change the static display string to a dynamic string that reads the display label from a resource bundle so train stop labels can be internationalized.
There are different strategies available for managing message bundles within an Oracle JDeveloper project. In this blog entry, I decided to build and configure the default properties file as indicated by the projects properties. To learn about the suggested file name and location, open the JDeveloper project properties (use a right mouse click on the project node in the Application Navigator and choose Project Properties.
Select the Resource Bundle node to see the suggested name and location for the default message bundle. Note that this is the resource bundle that Oracle JDeveloper would automatically create when you assign a text resource to an ADF Faces component in a page.
For the train stop display name, we need to create the message bundle manually as there is no context menu help available in Oracle JDeveloper. For this, use a right mouse click on the JDeveloper project and choose New | General | File from the menu and in the opened dialog.
Specify the message bundle file name as the name looked up before in the project properties Resource Bundle option. Also, ensure that the file is saved in a directory structure that matches the package structure shown in the Resource Bundle dialog. For example, you would save the properties file in the View Project's src > adf > sample directory if the package structure was "adf.sample" (adf.sample.ViewControllerBundle).
Edit the properties file and define key – values pairs for the train stop component. In the sample, such key value pairs are
TrainStop1=Train Stop 1
TrainStop2=Train Stop 2
TrainStop3=Train Stop 3
Next, double click the faces-config.xml file and switch the opened editor to the Overview tab. Select the Application category and press the green plus icon next to the Resource Bundle section.
Define the resource bundle Base Name as the package and properties file name, for example
adf.sample.ViewControllerBundle
Finally, define a variable name for the message bundle so the bundle can be accessed from Expression Language. For this blog example, the name is chosen as "messageBundle".
<resource-bundle> <base-name>adf.sample.ViewControllerBundle</base-name> <var>messageBundle</var> </resource-bundle>
Next, select the display-name element in the train stop node (similar to when creating the display name) and use the Property Inspector to change the static display string to an EL expression referencing the message bundle. For example:
#{messageBundle.TrainStop1}
At runtime, the train stops now show display names read from a message bundle (the properties file).
© Oracle Blogs or respective owner