在XML-View中使用自定义控件。部署后出错。找不到对象类

问题描述 投票:0回答:1

我开发了一个ui5应用程序,并在其中创建了一个新的自定义控件。我把新的控件js-文件保存到我的webapp的 "控件 "路径(在我的例子中,"MyControl "控件的文件MyInput.js)。在WebIDE中运行我的应用程序进行测试,没有任何问题。但是在将应用程序部署到abap系统后,我现在从XMLTemplateManager得到了错误信息,它找不到对象类。

这里是我的View使用我的Control的简短版本。

<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系统中会出现上述错误?

谢谢

sapui5
1个回答
1
投票

通过混合调试、尝试和错误,我自己解决了这个问题:-)

对于那些你正在运行到一个类似的问题,这里的解决方案.问题是我的控件的定义。所以,到目前为止,视图上面的所有东西(见我上面的问题)都是正常的。

但是我的(简化的测试-)控件是这样开始的。

    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版本1.54的情况下就不行了。解决这个问题的方法是用它的命名空间完全支持控件类。之后,我又遇到了另一个问题,我的renderer-function没有被定义。我只想继承扩展控件的渲染器,因为它不会对渲染本身做任何改变。这里的关键是将渲染器类设置在引号中。

所以这是我的完全工作的测试控件,现在可以在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);
            }

    });

把这个应用到我的 "真正的 "控件上,它就可以运行了:-)

尊敬的马蒂亚斯

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.