cancel
Showing results for 
Search instead for 
Did you mean: 

Change dataSources uri (manifest.json)

pablosilva80
Explorer
0 Kudos

Hi, brothers.

I need to change the uri before the call, how can I do it?

manifest.json

"dataSources": {
      "mainService": {
                    "uri": "http://sapmiidev:56500/XMII/IlluminatorOData/QueryTemplate?QueryTemplate=Interrupcoes/TelasPortal/RegistrarInterrupcao/Query/XQry_Interrupcoes_Sel_UI5",
                    "type": "JSON"
			}
		},

Component.js

sap.ui.define([

	"sap/ui/core/UIComponent",

	"sap/ui/Device",

	"mycompany/myapp/model/models",

	"mycompany/myapp/controller/ErrorHandler"

], function(UIComponent, Device, models, ErrorHandler) {

	"use strict";




	return UIComponent.extend("mycompany.myapp.Component", {




		metadata: {

			manifest: "json"

		},

		

		init: function() {

			

			//set param (variable session) in uri.

			this.getMetadata().getManifestEntry("sap.app").dataSources["mainService"].uri = 

				"http://sapmiidev:56500/XMII/IlluminatorOData/QueryTemplate?QueryTemplate=" +

				"Interrupcoes/TelasPortal/RegistrarInterrupcao/Query/XQry_Interrupcoes_Sel_UI5"+

				"&Param.1=xxx" + param;

						

			// call the base component's init function

			UIComponent.prototype.init.apply(this, arguments);

			// initialize the error handler with the component

			this._oErrorHandler = new ErrorHandler(this);




			// set the device model

			this.setModel(models.createDeviceModel(), "device");




			// create the views based on the url/hash

			this.getRouter().initialize();

		}

	});




});


Accepted Solutions (1)

Accepted Solutions (1)

junwu
Active Contributor

I think your url should be

http://sapmiidev:56500/XMII/IlluminatorOData/

the rest is composed when you call the odata.

pablosilva80
Explorer
0 Kudos

I studied OData, you're right.

I followed your tips and I'm almost there, the path:

path:'/Rowset(QueryTemplate=\'project/query\',RowsetId=1)/Row'
But still, I get error on NW server:

I'm investigating a way to set the token or ignore it.
Thanks

pablosilva80
Explorer
0 Kudos

I added and it worked.

"": {
       "dataSource": "mainService",
       "settings": {
       "disableHeadRequestForToken": true,
       "useBatch": false
    

Answers (2)

Answers (2)

pablosilva80
Explorer
0 Kudos

Pass all the overriding parameters as follows:

path:'/Rowset(QueryTemplate=\'query\',RowsetId=1)/Row?Param.1=<value>&Param.2=<value>'
francesco_alborghetti
Active Participant
0 Kudos

According to the documentation, manifest models are created before component initialization.

Since you are using a json model, is it an option to use loadData method with the new uri?

this.getModel().loadData(uri);
pablosilva80
Explorer
0 Kudos

If you do not have another option, yes. I would like to keep the manifest to minimize code. You know an event before manifest initialization?

Thanks francesco.alborghetti.