在我的SAPUI5应用程序中,我有一个OData操作,工作正常。现在我尝试显示成功消息,如果可以创建新条目,如果没有则显示错误消息。这是我的代码:
oModel.create("/ImportHeaders", oData, null,
function() {
sap.m.MessageBox.success("Interaction successfully created!", {
title: "Success",
initialFocus: null
});
},
function() {
sap.m.MessageBox.error("Interaction could not be created.", {
title: "Error",
initialFocus: null
});
}
);
这不显示任何消息框(如果操作成功与否则相等)。我做错了什么?
更新到I.B.Ns的答案。此代码实现了成功消息显示但是如果没有创建交互?有什么想法吗?
oModel.create("/ImportHeaders", oData, {
success: function() {
sap.m.MessageBox.success("Interaction successfully created!", {
title: "Success",
initialFocus: null
});
},
error: function() {
sap.m.MessageBox.error("Interaction could not be created.", {
title: "Error",
initialFocus: null
});
}
});
答案 0 :(得分:2)
Model.create方法参数是(sPath,oData,mParameters?),试试这个:
oModel.create("/ImportHeaders", oData, {
success: function() {
sap.m.MessageBox.success("Interaction successfully created!", {
title: "Success",
initialFocus: null
});
},
error: function() {
sap.m.MessageBox.error("Interaction could not be created.", {
title: "Error",
initialFocus: null
});
}
});