on 01-14-2014 1:43 PM
Hi Experts,
I am trying out the Application Header control in SAPUI5. I wanted to display the Application User that has logged in to Application to be displayed in the control. I tried to find the answer here but all the replies are specific to SAPUI5 on Netweaver, however I was wondering how to achieve this on the HANA XS Platform.
Any help would be appreciated.
Thanks and Regards,
Shreepad Patil
Thanks Angel and Philip,
I was also thinking in similar direction, but still I am not sure how to consume this XSJS service in the UI5 page.
In the UI5 view I have something as
var user = ???
oAppHeader.setUserName(user);
Can you please tell me how to assign the response from the XSJS to the user variable?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is a snippet of a function that we had with changes for your oAppHeader:
jQuery.ajax({
url : <path to xsjs script>,
async : false,
method : "GET",
dataType : 'json',
success : function(myJSON) {
oAppHeader.setUserName = myJSON.username;
},
error : function() {
oAppHeader.setUserName = "";
},
});
Hi,
ApplicationHeader element has username attribute:
Also Shell element:
Kind regards
We simply created a serverside javascript (xsjs) file that did the following and used the $.session.getUsername api call that is available and retrieved that in the UI5 code:
var body = '';
body = {
"username" : $.session.getUsername()
};
body = JSON.stringify(body);
$.response.status = $.net.http.OK;
$.response.content = 'application/json';
$.response.setBody(body);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shreepad,
Take a look to this post: http://scn.sap.com/thread/3474318
You could substitute PortalUser by a custom entity in Hana XS returning a JSON with user logged in HANA:
$.response.contentType = "application/json";
var output = "";
var conn = $.db.getConnection();
var pstmt = conn.prepareStatement( "SELECT CURRENT_USER FROM DUMMY" );
var rs = pstmt.executeQuery();
if (!rs.next()) {
$.response.setBody( "Failed to retrieve data" );
$.response.status = $.net.http.INTERNAL_SERVER_ERROR;
}
else {
output = '{ "user": "' + rs.getString(1) + '"}';
}
rs.close();
pstmt.close();
conn.close();
$.response.setBody(output);
Kind regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
9 | |
8 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.