我有一个适用于SAP Web IDE(个人版)的应用程序。我在我的后端系统中部署了应用程序,当我开始测试并且出乎我意料之外,在我尝试保存错误条目之后(想看看错误消息是否按预期发送),我收到了错误 "无法阅读财产' getParent'未定义" 。 "未定义"指的是我在基本控制器中使用的消息弹出窗口。异常不在我的代码中发生,但在 MessagePopover-dbg.js 中(下面附有快照,错误1209中的行)。
Web IDE上的SAPUI5版本:1.44.12
后端系统上的SAPUI5版本:1.44.23
基本控制器代码,以及调用下面附带的弹出窗口的例程。在其他情况下,我通常会向SAP发出一份说明,但由于我是SAPUI5的新成员,我并非100%确定我没有遗漏任何内容。有什么想法吗?
/********** Base Controller *************/
sap.ui.define([
"sap/ui/core/mvc/Controller",
"sap/ui/model/json/JSONModel",
"sap/m/MessagePopover",
"sap/m/MessagePopoverItem"
], function (Controller, JSONModel, MessagePopover, MessagePopoverItem) {
"use strict";
var oMessageTemplate = new MessagePopoverItem({
type: "{type}",
title: "{title}",
description: "{description}"
});
var oMessagePopover = new MessagePopover({
id: "actionEditMessagePopover",
items: {
path: '/',
template: oMessageTemplate
}
});
var msgModel = new JSONModel("testModel");
return Controller.extend("kristal.apps.agreements.controller.BaseController", {
/**
* Convenience method for accessing the router.
* @public
* @returns {sap.ui.core.routing.Router} the router for this component
*/
getRouter : function () {
return sap.ui.core.UIComponent.getRouterFor(this);
},
/**
* Convenience method for getting the view model by name.
* @public
* @param {string} [sName] the model name
* @returns {sap.ui.model.Model} the model instance
*/
getModel : function (sName) {
return this.getView().getModel(sName);
},
/**
* Convenience method for setting the view model.
* @public
* @param {sap.ui.model.Model} oModel the model instance
* @param {string} sName the model name
* @returns {sap.ui.mvc.View} the view instance
*/
setModel : function (oModel, sName) {
return this.getView().setModel(oModel, sName);
},
/**
* Getter for the resource bundle.
* @public
* @returns {sap.ui.model.resource.ResourceModel} the resourceModel of the component
*/
getResourceBundle : function () {
return this.getOwnerComponent().getModel("i18n").getResourceBundle();
},
/**
* Event handler when the share by E-Mail button has been clicked
* @public
*/
onShareEmailPress : function () {
var oViewModel = (this.getModel("objectView") || this.getModel("worklistView"));
sap.m.URLHelper.triggerEmail(
null,
oViewModel.getProperty("/shareSendEmailSubject"),
oViewModel.getProperty("/shareSendEmailMessage")
);
},
_renderSAPMessages: function(response, sStart, oControl) {
// Extract messages
// Catch logic works when we have multiple lines, re-initializes
// next line proccessing
this.messageArray = [];
var message;
var start = sStart + 14;
var resultString = response.substring(start);
var messageStart = resultString.indexOf("code") - 1;
var messageEnd = resultString.indexOf("details") - 2;
while (messageEnd > 0) {
message = "{" + resultString.substring(messageStart, messageEnd) + "}";
message = message.replace("severity\":", "type\": ");
//message = message.replace("message\":", "description\": ");
message = message.replace("message\":", "subtitle\": ");
message = message.replace("code\":", "title\": ");
message = message.replace("error", "Error");
message = message.replace("warning", "Warning");
message = message.replace("Z666Z", "\",\"description\": \"");
try {
message = JSON.parse(message);
message.title = message.title + " " + message.subtitle;
this.messageArray.push(message);
var streamEnd = resultString.indexOf("}]}") - 1;
messageEnd += 1;
if (streamEnd < messageEnd) {
// messageEnd = 0;
start = resultString.indexOf("sap-message: {") + 14;
if (start > 0) {
resultString = resultString.substring(start);
messageStart = resultString.indexOf("code") - 1;
messageEnd = resultString.indexOf("details") - 2;
} else {
messageEnd = 0;
}
} else {
resultString = resultString.substring(messageEnd);
messageStart = resultString.indexOf("code") - 1;
if (messageStart > 0) {
messageEnd = resultString.indexOf("}");
}
else {
break;
}
}
}
catch(err) {
start = resultString.indexOf("sap-message: {") + 14;
if (start > 0) {
resultString = resultString.substring(start);
messageStart = resultString.indexOf("code") - 1;
messageEnd = resultString.indexOf("details") - 2;
} else {
messageEnd = 0;
}
}
}
msgModel.setData(this.messageArray);
oMessagePopover.setModel(msgModel);
if (this.messageArray.length > 0) {
oMessagePopover.openBy(oControl);
}
},
_checkIfBatchRequestSucceeded: function(oEvent) {
var oParams = oEvent.getParameters();
var aRequests = oEvent.getParameters().requests;
var oRequest;
if (oEvent.getParameters().response.responseText.indexOf("sap-message: {") !== null) {
return true;
}
else
{
if (oParams.success) {
if (aRequests) {
for (var i = 0; i < aRequests.length; i++) {
oRequest = oEvent.getParameters().requests[i];
if (!oRequest.success) {
return false;
}
}
}
return true;
} else {
return false;
}
}
},
_checkMessagePopoverState: function() {
if (oMessagePopover.isOpen()) {
oMessagePopover.close();
}
}
});
}
);
/************ Call to Popover **************/
onHeaderSave: function() {
var that = this;
var oModelUpdateDeferred = jQuery.Deferred();
var bCheckSuccess;
var oModel = this.getView().getModel();
this._checkMessagePopoverState();
// abort if the model has not been changed
if (!oModel.hasPendingChanges()) {
MessageBox.information(
this.getResourceBundle().getText("noChangesMessage"), {
id: "noChangesInfoMessageBox",
styleClass: that.getOwnerComponent().getContentDensityClass()
}
);
return;
}
oModel.attachEventOnce("batchRequestCompleted", function(oEvent) {
// Get control to display message list next to
var oControl = sap.ui.getCore().byId("application-agreements-display-component---object--objectAgreementHeaderForm");
if (that._checkIfBatchRequestSucceeded(oEvent)) {
that._renderSAPMessages(oEvent.getParameters().response.responseText,
oEvent.getParameters().response.responseText.indexOf("sap-message: {"),
oControl);
if (oEvent.getParameters().response.responseText.indexOf("sap-message: {") < 0) {
bCheckSuccess = true;
} else {
bCheckSuccess = false;
}
oModelUpdateDeferred.resolve();
}
});
oModel.submitChanges({
success: function(oData, sResponse) {
},
error: function(oError) {
jQuery.sap.log.error("oData Failure", oError);
}
});
var readyToGo = function() {
if (bCheckSuccess === true) {
this.getView().byId("saveHeaderButton").setVisible(false);
this.getView().byId("cancelHeaderButton").setVisible(false);
this.getView().byId("editHeaderButton").setVisible(true);
this._bindHeaderReadOnly();
}
};
jQuery.when(oModelUpdateDeferred).done().then( jQuery.proxy(readyToGo, this) );
}
答案 0 :(得分:0)
这不是像'I.B.N那样的流行音乐。在评论部分注意到,问题是负责屏幕上弹出位置的控件的声明。它是使用sap.ui.getCore()和控件的完全限定路径声明的,这是非常不明智的,因为它在运行时和不同环境中动态生成可能会发生变化......