SAPUI5 和 NW 门户
SAPUI5 and NW Portal
我在我的门户上部署了一个 SAPUI5 应用程序。
我正在尝试让用户登录登录到我的 SAPUI5 中的门户。
但是当我 运行 我的应用程序没有得到任何数据时。
下面是我的代码
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, "user", "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: {
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;
});
`
var oUserData;
var y = "/sap/bc/ui2/start_up";
var xmlHttp = null;
xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
oUserData = JSON.parse(xmlHttp.responseText);
}
};
xmlHttp.open("GET", y, false);
xmlHttp.send(null);
`
控制台 oUserData 以获取登录用户的登录详细信息。
据我所知,你说的是 SAP 门户,我希望你有 7.3+ 版本。
我找到了您用来查找用户的 SAP 文档,请小心,因为这不是门户网站上的 SAPUI5 应用程序 运行 的代码,而是 [=] 上的一个 运行 30=] 系统,端点 /sap/bc/ui2/start_up 在 NetWeaver 门户上不存在。
您可以做的是开发一个简单的 REST 服务(通过开发 Servlet),该服务将发回用户和您需要的所有详细信息。
这些详细信息可以在包含 IUser 对象的 PortalComponentRequest 中找到,您可以在我的 Git 此处找到示例门户 servlet:
https://gitlab.com/Almiriad/sap-portal-samples
您只需向 url 发送 GET 请求
http[s]://youserver:你的port/irj/servlet/prt/portal/prtroot/UserServletSample.UserInfoSampleServlet
你会得到一个 JSo
{
"user": {
"user-name":"<LASTNAME>, <FIRSTNAME>",
"user-id":"<USER_ID>",
"user-email":"<USER@EMAIL.COM>"
}
}
希望对您有所帮助。
我在我的门户上部署了一个 SAPUI5 应用程序。 我正在尝试让用户登录登录到我的 SAPUI5 中的门户。
但是当我 运行 我的应用程序没有得到任何数据时。
下面是我的代码
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, "user", "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: {
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;
});
`
var oUserData;
var y = "/sap/bc/ui2/start_up";
var xmlHttp = null;
xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
oUserData = JSON.parse(xmlHttp.responseText);
}
};
xmlHttp.open("GET", y, false);
xmlHttp.send(null);
`
控制台 oUserData 以获取登录用户的登录详细信息。
据我所知,你说的是 SAP 门户,我希望你有 7.3+ 版本。
我找到了您用来查找用户的 SAP 文档,请小心,因为这不是门户网站上的 SAPUI5 应用程序 运行 的代码,而是 [=] 上的一个 运行 30=] 系统,端点 /sap/bc/ui2/start_up 在 NetWeaver 门户上不存在。
您可以做的是开发一个简单的 REST 服务(通过开发 Servlet),该服务将发回用户和您需要的所有详细信息。 这些详细信息可以在包含 IUser 对象的 PortalComponentRequest 中找到,您可以在我的 Git 此处找到示例门户 servlet:
https://gitlab.com/Almiriad/sap-portal-samples
您只需向 url 发送 GET 请求 http[s]://youserver:你的port/irj/servlet/prt/portal/prtroot/UserServletSample.UserInfoSampleServlet 你会得到一个 JSo
{
"user": {
"user-name":"<LASTNAME>, <FIRSTNAME>",
"user-id":"<USER_ID>",
"user-email":"<USER@EMAIL.COM>"
}
}
希望对您有所帮助。