Skip to Content
0

Change dataSources uri (manifest.json)

Mar 07 at 08:12 PM

176

avatar image
Former Member

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();

		}

	});




});


10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Jun Wu Mar 08 at 05:27 AM
1

I think your url should be

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

the rest is composed when you call the odata.

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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

0
Former Member
Former Member

I added and it worked.

"": {
       "dataSource": "mainService",
       "settings": {
       "disableHeadRequestForToken": true,
       "useBatch": false
    
0
Francesco Alborghetti Mar 07 at 09:00 PM
0

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);
Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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.

0
avatar image
Former Member Mar 11 at 12:18 PM
0

Pass all the overriding parameters as follows:

path:'/Rowset(QueryTemplate=\'query\',RowsetId=1)/Row?Param.1=<value>&Param.2=<value>'
Share
10 |10000 characters needed characters left characters exceeded