2 Replies Latest reply on May 27, 2015 7:40 PM by 1007049

    Dynamic labels for attributes in Entity object

    1007049

      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

        • 1. Re: Dynamic labels for attributes in Entity object
          Ruben Rodriguez

          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";
               String config = "the_configuration_name_to_use";
               ApplicationModule am = Configuration.createRootApplicationModule(amDef, config);
               Map map = am.getResourceBundle(locale);
               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

          1 person found this helpful
          • 2. Re: Dynamic labels for attributes in Entity object
            1007049

            Hi Ruben,

            Thanks for the code. Will give it a try.