如何在SAP UI5中将OData绑定至mailTo功能按钮?
SAP UI5表单按钮绑定OData实现邮件发送功能
我有一个SAP UI5表单,表单底部设有一个按钮,需实现将表单内容发送至指定邮箱的功能。基于ABAP开发的后端部分已完成,我已获取到可用的OData地址。现在需要在UI5中实现该按钮与该OData的绑定,以下是我目前编写的代码:
controller.js代码
onInit: function () { this.getView().byId("html").setContent("<canvas id='signature-pad' width='100' height='80' class='signature-pad' style='border:1px' ></canvas>"); var oModel = new JSONModel({ checkboxes: [""], checkboxes2: [""], checkboxes3: [""] }); this.getView().setModel(oModel); var mailToButton = new sap.m.Button({ text: "Send Email", id: "mailTo", oDataBinding: { path: "/sap/opu/odata/JOHN/JOHN_FORMULAR_SRV/SendMail?Body='Test'&RecieverList='john.doe@hotmail.com'&Subject='TestSubject'", success: function(data) { var email = data.Email; window.open("mailto:" + email); }, error: function(error) { console.log(error); } } });
manifest.json代码
{ "_version": "1.3.0", "sap.app": { "id": "opensap.myapp", "type": "application", "title": "{{appTitle}}", "description": "{{appDescription}}", "applicationVersion": { "version": "1.0.0" } }, "sap.ui": { "_version": "1.3.0", "technology": "UI5", "deviceTypes": { "desktop": true, "tablet": true, "phone": true } }, "dataSources": { "cuProxyRemote": { "uri": "/sap/opu/odata/JOHN/JOHN_FORMULAR_SRV/SendMail?Body='Test'&RecieverList='john.doe@hotmail.com'&Subject='TestSubject'", "type": "OData", "settings": { "odataVersion": "2.0" } } }, "sap.ui5": { "_version": "1.3.0", "rootView": { "viewName": "opensap.myapp.view.App", "type": "XML", "async": true, "id": "app" }, "autoPrefixId": true, "dependencies": { "minUI5Version": "1.34", "libs": { "sap.ui.core": {"minVersion": "1.34.0"}, "sap.m": {"minVersion": "1.34.0"}, "sap.ui.layout": {"minVersion": "1.34.0"} } }, "cuProxy": { "dataSource": "cuProxyRemote" }, "models": { "i18n": { "type": "sap.ui.model.resource.ResourceModel", "settings": { "bundleName": "opensap.myapp.i18n.i18n" } }, "MyViewModel": { "type": "sap.ui.model.json.JSONModel" } }, "resources": { "css": [ { "uri": "css/style.css" } ] }, "contentDensities": { "compact": true, "cozy": true } } }
XML视图尝试的绑定代码
<Button value="{/mailTo}" text="Send" press="btnHandler" id="mailTo"></Button>
内容的提问来源于stack exchange,提问作者boba_fett
相关产品推荐
相关产品推荐

