如何获取 POST 最佳实践 CRUD 数据(更新)
How to get POST Data on Best Practice CRUD (Update)
我们想更新/编辑客户的数据。所以我们已经尝试了示例中的原始代码。该示例运行良好,但我们通常必须在将其写入数据库之前检查用户输入。这是我的代码:
/**
* Event handler (attached declaratively) for the view save button. Saves the changes added by the user.
* @function
* @public
*/
onSave: function() {
var that = this,
oModel = this.getModel();
// abort if the model has not been changed
if (!oModel.hasPendingChanges()) {
MessageBox.information(
this._oResourceBundle.getText("keine Änderungen"), {
id: "noChangesInfoMessageBox",
styleClass: that.getOwnerComponent().getContentDensityClass()
}
);
return;
}
this.getModel("appView").setProperty("/busy", true);
if (this._oViewModel.getProperty("/mode") === "edit") {
// attach to the request completed event of the batch
oModel.attachEventOnce("batchRequestCompleted", function(oEvent) {
var oParams = oEvent.getParameters();
if (oParams.success) {
that._fnUpdateSuccess();
} else {
that._fnEntityCreationFailed();
}
});
}
oModel.submitChanges();
},
我如何访问请求数据?我试图查看 oModel DOM,但只发现 aBindings
那里有很多无用的东西。甚至 window.location.search
也不是解决方案。
我们已经修复了它。
只需使用this._getFormFields(this.byId("newEntitySimpleForm"));
我们想更新/编辑客户的数据。所以我们已经尝试了示例中的原始代码。该示例运行良好,但我们通常必须在将其写入数据库之前检查用户输入。这是我的代码:
/**
* Event handler (attached declaratively) for the view save button. Saves the changes added by the user.
* @function
* @public
*/
onSave: function() {
var that = this,
oModel = this.getModel();
// abort if the model has not been changed
if (!oModel.hasPendingChanges()) {
MessageBox.information(
this._oResourceBundle.getText("keine Änderungen"), {
id: "noChangesInfoMessageBox",
styleClass: that.getOwnerComponent().getContentDensityClass()
}
);
return;
}
this.getModel("appView").setProperty("/busy", true);
if (this._oViewModel.getProperty("/mode") === "edit") {
// attach to the request completed event of the batch
oModel.attachEventOnce("batchRequestCompleted", function(oEvent) {
var oParams = oEvent.getParameters();
if (oParams.success) {
that._fnUpdateSuccess();
} else {
that._fnEntityCreationFailed();
}
});
}
oModel.submitChanges();
},
我如何访问请求数据?我试图查看 oModel DOM,但只发现 aBindings
那里有很多无用的东西。甚至 window.location.search
也不是解决方案。
我们已经修复了它。
只需使用this._getFormFields(this.byId("newEntitySimpleForm"));