Forum Stats

  • 3,770,515 Users
  • 2,253,129 Discussions
  • 7,875,493 Comments

Discussions

Dynamic labels for attributes in Entity object

Ravi4-Oracle
Ravi4-Oracle Member Posts: 131 Employee
edited May 27, 2015 3:40PM in JDeveloper and ADF

Hi,

I am trying to set the labels on the entity attributes by getting the value from Database. Here is a article I am referring  -

https://technology.amis.nl/2012/08/10/implement-resource-bundles-for-adf-applications-in-a-database-table

But this article is getting dynamic labels at the viewcontroller.

I want to do the same thing at the Model layer so that the labels are set on the entity object attribute (in the UI Hints tab) so that wherever this attribute is used the labels get reflected in all the pages.

I am not able to find how to use groovy expression or set the label dynamically on the entity attribute.

Can this be achieved ?

If anyone has tried it before or any pointers will be helpful.

Thanks.

JDev - 11.1.2.4

Answers

  • Ruben Rodriguez
    Ruben Rodriguez Member Posts: 351 Gold Badge
    edited May 23, 2015 7:25PM

    Hello,

    I have never done this in the model, but you could try to do the same but in the DBResourceBundle.java class call AM method getResourceBundle like this:


    getResourceBundle(String locale){

         String amDef = "your.fully.qualified.class.name.of.the.application.module";<br/>     String config = "the_configuration_name_to_use";<br/>     ApplicationModule am = Configuration.createRootApplicationModule(amDef, config);<br/>     Map map = am.getResourceBundle(locale);<br/>     Configuration.releaseApplicationModule(am, false);

              return map;

    }

    Then, in your entity.xml you should have this reference:

         <ResourceBundle>

             <JavaResourceBundle MsgBundleClass="path.to.DBResourceBundle"/>

          </ResourceBundle>

    and in the attribute something like this:

         <Attribute

             Name="AttrName"

             ...>

             <Properties>

               <SchemaBasedProperties>

                 <LABEL ResId="LABEL_KEY_IN_DB"/>

               </SchemaBasedProperties>

             </Properties>

          </Attribute>

    regards,

    Ruben

    Ravi4-Oracle
  • Ravi4-Oracle
    Ravi4-Oracle Member Posts: 131 Employee
    edited May 27, 2015 3:40PM

    Hi Ruben,

    Thanks for the code. Will give it a try.

This discussion has been closed.