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

    Dynamic labels for attributes in Entity object




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



      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.




      JDev -

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



          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:



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



          and in the attribute something like this:







                       <LABEL ResId="LABEL_KEY_IN_DB"/>








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

            Hi Ruben,

            Thanks for the code. Will give it a try.