2017-10-04 17 views
1

SAPUI5에서는 여러 가지 방법으로 항목에 자원 번들 속성을 바인딩 할 수 있습니다. 오다타 서비스에서 제공하는 데이터를 사용하여 JavaScript로 처리하려고 시도했지만, 지금까지 발견 한 메소드는 작동하지 않았습니다.목록에 대한 ResourceBundle 속성 바인딩

  1. How to Use Internalization i18n in a Controller in SAPUI5?

  2. binding issue with sap.m.List and model configured in manifest.json

그리고이 중 어느 것도 일한 : 나는 두 가지 방법을 시도했습니다. 내가 대화의 내부하는 항목 목록 안에이기 때문에이 느낌이 내 문제를 일으키는 :

내 코드는 다음과 같습니다

var resourceBundle = this.getView().getModel("i18n"); 

if (!this.resizableDialog) { 
    this.resizableDialog = new Dialog({ 
     title: 'Title', 
     contentWidth: "550px", 
     contentHeight: "300px", 
     resizable: true, 
     content: new List({ 
      items: { 
       path: path, 
       template: new StandardListItem({ 
        title: resourceBundle.getProperty("{Label}"),//"{ path : 'Label', fomatter : '.getI18nValue' }", 
        description: "{Value}" 
       }) 
      } 
     }), 
     beginButton: new Button({ 
      text: 'Close', 
      press: function() { 
       this.resizableDialog.close(); 
      }.bind(this) 
     }) 
    }); 

getI18nValue : function(sKey) { 
    return this.getView().getModel("i18n").getProperty(sKey); 
}, 

위의 두번째 방법을 사용하여, 결코 JavaScript 메서드를 호출합니다. 더 많은 JSON을 기반으로하므로 작동하지 않을 것이라고 생각했습니다. 첫 번째 방법은 데이터를 잘로드하지만 리소스 번들 텍스트를 표시하는 대신 {Label} 값 내부에있는 텍스트 만 표시합니다. 당신이보기에있는 것 같은

{Label} 내부에 발견 값은 앞의 i18n>없이 Resouce의 번들 즉 내부에 발견 키를 일치합니다.

누구든지 의견이 있으십니까?

답변

1

포맷터을 사용하면 문제가 해결되지만 잘못된 방법입니다. 이것을 시도하면 문제가 해결됩니다.

var resourceBundle = this.getView().getModel("i18n"); 
if (!this.resizableDialog) { 
    this.resizableDialog = new Dialog({ 
     title: 'Title', 
     contentWidth: "550px", 
     contentHeight: "300px", 
     resizable: true, 
     content: new List({ 
      items: { 
       path: path, 
       template: new StandardListItem({ 
        title: { 
         parts: [{ path: "Label" }], 
         formatter: this.getI18nValue.bind(this) 
        }, 
        description: "{Value}" 
       }) 
      } 
     }), 
     beginButton: new Button({ 
      text: 'Close', 
      press: function() { 
       this.resizableDialog.close(); 
      }.bind(this) 
     }) 
    }); 
} 

그리고 포맷 기능 getI18nValue과 같이 될 것

getI18nValue: function(sKey) { 
    return this.getView().getModel("i18n").getResourceBundle().getText(sKey); 
},