XML-View 中的自定义控件用法。部署后出错:找不到对象 class
Custom Control usage in XML-View. Error after deployment: Can't find object class
我开发了一个 ui5 应用程序并在其中创建了一个新的自定义控件。我将新的控件 js 文件保存到我的 Web 应用程序的 "control" 路径(在我的示例中,控件 'MyControl' 的文件 MyInput.js)。
运行 我在 WebIDE 中测试的应用程序运行没有任何问题。但是在将应用程序部署到 abap 系统后,我现在从 XMLTemplateManager 收到错误消息,它找不到对象 class.
这里是使用我的控件的视图的简化版本:
<mvc:View xmlns:mvc="sap.ui.core.mvc" xmlns="sap.uxap" xmlns:layout="sap.ui.layout" xmlns:m="sap.m" xmlns:forms="sap.ui.layout.form"
xmlns:core="sap.ui.core" xmlns:ssuc="sap.suite.ui.commons" xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:table="sap.ui.table" xmlns:cmns="sap.ui.commons"
xmlns:dvp="de.fiori4cls.Fi4ClsFV.control"
controllerName="de.fiori4cls.Fi4ClsFV.controller.FVView" displayBlock="true">
<m:Shell id="shell">
<m:App id="app">
<m:pages>
<m:Page id="fvViewPage" title="{i18n>SachPruef}">
<m:content>
<dvp:MyInput
value="{ path : 'Cls>/Currency', type : 'sap.ui.model.type.String' }"
vhTitle="{i18n>Currency}"/>
</m:content>
</m:Page>
</m:pages>
</m:App>
</m:Shell>
</mvc:View>
此处 'de.fiori4cls.Fi4ClsFV' 是我的应用程序的 ID(如 manifest.json 部分 'sap.app' 属性 'id' 下的声明。
知道为什么它在 WebIDE 测试中运行以及为什么在部署到 abap 系统时抛出上述错误吗?
亲切的问候
马蒂亚斯
自己通过调试、尝试和错误的组合解决了问题:-)
对于那些你运行遇到类似问题的人,这里有解决方案。
问题是我的控件的定义。所以到目前为止,视图上方的所有内容(请参阅我上面的问题)都没有问题。
但是我的(简化测试-)控制启动是这样的:
return Input.extend("MyInput", {
"metadata": {
"properties": {
// Title of Value-Help Dialog
"vhTitle" : { type : "string", defaultValue :"Title" }
}
},
init : function() {
// Call inherited Method
Input.prototype.init.call(this);
this.setShowValueHelp(true);
this.attachValueHelpRequest(this.onValueHelpRequest);
},
renderer: sap.m.InputRenderer,
// ======= Events
onValueHelpRequest : function(oEvent) {
var me = this;
console.log("MyInput->onValueHelpRequest->Entering");
var lvTitle = this.getVhTitle();
alert (lvTitle);
}
});
我发现这与 UI5 1.54 及更高版本一起运行。但不是 UI5 版本 blow 1.54。
解决问题的方法是完全支持 control-class 及其命名空间。之后我 运行 遇到了另一个问题,即我的渲染器函数未定义。我只想继承扩展控件的渲染器,因为它不会对渲染本身进行任何更改。这里的关键是将 renderer-class 设置在引号中。
所以这是我现在可以在 ui5 1.44 及更高版本上运行的完全可用的测试控件。
return Input.extend("de.fiori4cls.Fi4ClsFV.control.MyInput", {
"metadata": {
"properties": {
// Title of Value-Help Dialog
"vhTitle" : { type : "string", defaultValue :"Title" }
}
},
init : function() {
// Call inherited Method
Input.prototype.init.call(this);
this.setShowValueHelp(true);
this.attachValueHelpRequest(this.onValueHelpRequest);
},
renderer: "sap.m.InputRenderer",
// ======= Events
onValueHelpRequest : function(oEvent) {
var me = this;
console.log("MyInput->onValueHelpRequest->Entering");
var lvTitle = this.getVhTitle();
alert (lvTitle);
}
});
将此应用于我的 "real" 控件使其成为 运行 :-)
亲切的问候
马蒂亚斯
我开发了一个 ui5 应用程序并在其中创建了一个新的自定义控件。我将新的控件 js 文件保存到我的 Web 应用程序的 "control" 路径(在我的示例中,控件 'MyControl' 的文件 MyInput.js)。 运行 我在 WebIDE 中测试的应用程序运行没有任何问题。但是在将应用程序部署到 abap 系统后,我现在从 XMLTemplateManager 收到错误消息,它找不到对象 class.
这里是使用我的控件的视图的简化版本:
<mvc:View xmlns:mvc="sap.ui.core.mvc" xmlns="sap.uxap" xmlns:layout="sap.ui.layout" xmlns:m="sap.m" xmlns:forms="sap.ui.layout.form"
xmlns:core="sap.ui.core" xmlns:ssuc="sap.suite.ui.commons" xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:table="sap.ui.table" xmlns:cmns="sap.ui.commons"
xmlns:dvp="de.fiori4cls.Fi4ClsFV.control"
controllerName="de.fiori4cls.Fi4ClsFV.controller.FVView" displayBlock="true">
<m:Shell id="shell">
<m:App id="app">
<m:pages>
<m:Page id="fvViewPage" title="{i18n>SachPruef}">
<m:content>
<dvp:MyInput
value="{ path : 'Cls>/Currency', type : 'sap.ui.model.type.String' }"
vhTitle="{i18n>Currency}"/>
</m:content>
</m:Page>
</m:pages>
</m:App>
</m:Shell>
</mvc:View>
此处 'de.fiori4cls.Fi4ClsFV' 是我的应用程序的 ID(如 manifest.json 部分 'sap.app' 属性 'id' 下的声明。
知道为什么它在 WebIDE 测试中运行以及为什么在部署到 abap 系统时抛出上述错误吗?
亲切的问候 马蒂亚斯
自己通过调试、尝试和错误的组合解决了问题:-)
对于那些你运行遇到类似问题的人,这里有解决方案。 问题是我的控件的定义。所以到目前为止,视图上方的所有内容(请参阅我上面的问题)都没有问题。
但是我的(简化测试-)控制启动是这样的:
return Input.extend("MyInput", {
"metadata": {
"properties": {
// Title of Value-Help Dialog
"vhTitle" : { type : "string", defaultValue :"Title" }
}
},
init : function() {
// Call inherited Method
Input.prototype.init.call(this);
this.setShowValueHelp(true);
this.attachValueHelpRequest(this.onValueHelpRequest);
},
renderer: sap.m.InputRenderer,
// ======= Events
onValueHelpRequest : function(oEvent) {
var me = this;
console.log("MyInput->onValueHelpRequest->Entering");
var lvTitle = this.getVhTitle();
alert (lvTitle);
}
});
我发现这与 UI5 1.54 及更高版本一起运行。但不是 UI5 版本 blow 1.54。 解决问题的方法是完全支持 control-class 及其命名空间。之后我 运行 遇到了另一个问题,即我的渲染器函数未定义。我只想继承扩展控件的渲染器,因为它不会对渲染本身进行任何更改。这里的关键是将 renderer-class 设置在引号中。
所以这是我现在可以在 ui5 1.44 及更高版本上运行的完全可用的测试控件。
return Input.extend("de.fiori4cls.Fi4ClsFV.control.MyInput", {
"metadata": {
"properties": {
// Title of Value-Help Dialog
"vhTitle" : { type : "string", defaultValue :"Title" }
}
},
init : function() {
// Call inherited Method
Input.prototype.init.call(this);
this.setShowValueHelp(true);
this.attachValueHelpRequest(this.onValueHelpRequest);
},
renderer: "sap.m.InputRenderer",
// ======= Events
onValueHelpRequest : function(oEvent) {
var me = this;
console.log("MyInput->onValueHelpRequest->Entering");
var lvTitle = this.getVhTitle();
alert (lvTitle);
}
});
将此应用于我的 "real" 控件使其成为 运行 :-)
亲切的问候 马蒂亚斯