Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Put constant inside binding

Hi,

There is a way inside binding to put some constant

instead of

  new sap.ui.commons.TextView({
  text: "{FILENAME}",

  new sap.ui.commons.TextView({
  text: constant "{FILENAME}",

Tags:
Former Member
Former Member replied

IMO, Sai's solution is good.

However, we have to be careful if the text is localized. Then it is better not to do string concatenation but have a sap.ui.model.resource.ResourceModel to defined the format.

then you can do

var oTextView = new sap.ui.commons.TextView({
    text: {
       parts: ['i18n>localizedStr', 'FILENAME'],
       formatter: function(localizedString, filename) {
           return localizedString.replace('{0}', filename);
       }
    }
});

Where i18n is the resource model and example of localizedStr is

constant {0}

Thanks

-D

3 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question