cancel
Showing results for 
Search instead for 
Did you mean: 

Linking json model with resource model

Former Member
0 Kudos
208

Hi All,

On setting json model for example data1.json to view, I want i18n>submit to be displayed on the button. The same button should display i18n>cancel on setting data2.json. How can I achieve this? Please let me know the source wherein I can know all about this.

Sorry for my ignorance.

Thanks in advance.

View Entire Topic
saxos
Explorer
0 Kudos

Hi Kumar,

load your i18n model and bind it to your view or core as follow:

than I wrote i function where i can get the i18n texts like:

geti18n: function(sMsg) {
return sap.ui.getCore().getModel("i18n").getResourceBundle().getText(sMsg);

},

sMsg is the i18n code.

just give your button an ID. Than you can set the text like this.getView().byId("myButton").setText(geti18n('submit'));

haven't tried it but should work.

Regards,

Samuel

Former Member
0 Kudos

Thank you very much for your reply.

I got the answer. I used the formatter function in button text to achieve.

Here is how I got it.

new sap.ui.commons.Button("Button1",{

  text: { path: 'screen>/finalButt1',

      formatter: function(s) {

         return sap.ui.getCore().getModel("i18n").getResourceBundle().getText(s);

      }

  },

  press : function(){

  oController.onSubmit();

  }

  });