Skip to Content
0

SAPUI5 and NW Portal

Apr 03, 2017 at 01:15 PM

99

avatar image

I have an SAPUI5 application deployd on my portal.
I am trying get the user login logged on portal in my SAPUI5.

But when I run my application it is not get any data.

Bellow is my code

#controller

sap.ui.define([ 'jquery.sap.global', 'sap/ui/core/Fragment', 'sap/ui/core/mvc/Controller', 'sap/ui/model/Filter', 'sap/ui/model/json/JSONModel' ], function(jQuery, Fragment, Controller, Filter, JSONModel) { "use strict"; var CController = Controller.extend("sap.m.ZHRUI001.C", { inputId: '', valueHelpRequest: function(oController) { this.inputId = oController.oSource.sId; var sServiceUrl = "“http://<my server host>:<my server port>/sap/bc/ui2/start_up";
var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl, true, "username", "password"); var oJsonModel = new sap.ui.model.json.JSONModel(); oModel.read("/?", null, null, true, function(oData, response) { oJsonModel.setData(oData); }); sap.ui.getCore().setModel(oJsonModel); // Handling of both confirm and cancel; clear the filter var that = this; var handleClose = function(oEvent) { var oSelectedItem = oEvent.getParameter("selectedItem"); if (oSelectedItem) { that.byId(that.inputId).setValue(oSelectedItem.getTitle()); } oEvent.getSource().getBinding("items").filter([]); }; // Create a SelectDialog and display it; bind to the same // model as for the suggested items if (!this._valueHelpSelectDialog) { this._valueHelpSelectDialog = new sap.m.SelectDialog("valueHelpSelectDialog", { title: "{fullName}", items: { path: "", template: new sap.m.StandardListItem({ title: "{fullName}", active: true }) }, search: function(oEvent) { var sValue = oEvent.getParameter("value"); var oFilter = new sap.ui.model.Filter( "name", sap.ui.model.FilterOperator.Contains, sValue ); oEvent.getSource().getBinding("items").filter([oFilter]); }, confirm: handleClose, cancel: handleClose }); this._valueHelpSelectDialog.setModel(oJsonModel); } else { this._valueHelpSelectDialog.setModel(oJsonModel); } this._valueHelpSelectDialog.open(); } }); return CController; });
10 |10000 characters needed characters left characters exceeded

Hi,

Is SSO configured between portal and backend Odata service?

If SSO is configured between portal and backend system(R/3), there is not need to pass username and password when calling OData.

Thanks,

Dheeram

0

HI Dheeram,

I test this same code with other Odata Service and it works.

But in the other code I used a path

0

can someone help me?

0

Hi,

In Google Chrome F12, check network tab. Should see a request to backend system when read is called.

Change ODataModel, like as shown below:

var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl, {json:true, user:"username", password:"password"});

Second parameter is a JS object.

Note: Please try to use version 2 of ODataModel.

Thanks,

Dheeram

0
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Arun Singh Apr 05, 2017 at 08:03 AM
0

Hi Rubens,

Can you check this blog for getting the logged-in user details.

Regards

Arun

Show 1 Share
10 |10000 characters needed characters left characters exceeded

I saw this blog and used it to do my code.

But my code didn't work

0