1
在SAPUI5中,通常可以通过多种方式将资源包属性绑定到项目。我正在尝试使用Odata服务提供的数据在JavaScript中执行此操作,但目前为止我在这里找到的方法没有奏效。我已经试过两种不同的方式:将ResourceBundle属性绑定到列表项
而且,无论这些都工作过。我觉得这是因为我是一个项目列表里面,一个对话框,里面是造成我的问题:
我的代码是:
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>
,就像您在视图中看到的一样。
任何人有任何建议吗?