Hello everyone,
I have a question regarding how to invoke JSON data through a .js file. After loading a service into a Model, the content is not being displayed on html. Instead, only signals are shown as if the model was blank.
Here's my code
File: RetrieveData.xsjs
... function doGet() { try { $.response.contentType = "application/json"; $.response.setBody(JSON.stringify("<local method return, should be a string value>")); <-- the content has not been passed catch (err) { $.response.contentType = "text/plain"; $.response.setBody(); $.response.returnCode = $.net.http.OK; } } ...
File: RetrieveData.view.js
sap.ui.jsview("views.RetrieveData", { getControllerName : function() { return "views.RetrieveData"; } createContent: function(oController) { var oMatrix = new sap.ui.commons.layout.MatrixLayout({ ... }); var retrieveDataModel = new sap.ui.model.json.JSONModel(); retrieveDataModel.loadData("services/retrieveData.xsjs"); var oText = new sap.ui.commons.TextView(); oText.setText(retrieveDataModel.getJSON()); var oCell = new sap.ui.commons.layout.MatrixLayoutCell(); oCell.addContent(oText); oMatrix.createRow(oCell); return oMatrix; }
Regards,
Arthur Silva