Page 1 of 1
Username in Anonymous-program - from userSpan ?
Posted: Tue Jun 25, 2013 2:59 pm
by georg.merten
Hi,
I've created a anonymous progam which is running in an iFrame of my start.html
body of start.html:
Code: Select all
<div id="main">
<div id="left"><div id="5250"></div>
<div id="right"><iframe width="210px" height="705px" frameborder="0" src="http://10.32.64.6:8080/profoundui/start?pgm=CDMSOTST/CDMTST01O">
</iframe></div></div>
</div>
<span id="userSpan">
That means the user logs into the normal profound session and has always the possibilty to use the anonymous program on the right side of the application.
do you think it is possible to get the username from userSpan ID and work with it in the anonymous program ? Or do you see another possiblity to get the user profile which logged into the profound session?
see attached picture of the login screen to make it more clear...
Re: Username in Anonymous-program - from userSpan ?
Posted: Tue Jun 25, 2013 6:12 pm
by Scott Klement
There's a currentUser() routine that you can call to get the userid that is signed on to the Profound UI session.
http://www.profoundlogic.com/docs/displ ... User%28%29
Some Genie skins will use this (or, the related, pui["appJob"]["user"]) to create an element named userSpan that shows the user who is signed in, but these userSpans will usually have something extra in them like "Welcome THEUSER" or "Hello THEUSER"... so it's easier to just call currentUser(), that way you don't have to substring off the "Welcome" or "Hello" (or whatever message someone may dream up in the future.)
Re: Username in Anonymous-program - from userSpan ?
Posted: Tue Jun 25, 2013 7:02 pm
by Scott Klement
I should clarify that currentUser() will do something different depending on where it's called. If you call it from within the main page (the Genie page) it'll give you the userid of that session. If you call it from the iFrame, it won't give you a real userid, because that session is anonymous.
One solution, from the iframe, you could just call parent.currentUser(), you'll get the userid of the parent window (the Genie window). But -- please don't use this for anything that needs to be secure, because it would be very easy to spoof the userid in this case.
Maybe it's best to take a step back, here... Why do you want the userid in the iframe? What will you use it for?
Re: Username in Anonymous-program - from userSpan ?
Posted: Wed Jun 26, 2013 3:43 am
by georg.merten
cool! parent. is working fine.
I want that the user has during the whole session the possibilty to change defaults from his profile of our application. Like default printer/client/environment...
Re: Username in Anonymous-program - from userSpan ?
Posted: Wed Jun 26, 2013 3:58 am
by georg.merten
does something like child. exist?
next step would be child.pui.click() ?
so that the "user-session" refresh the anonymous session.
parent.pui.click() is working...
Re: Username in Anonymous-program - from userSpan ?
Posted: Thu Jun 27, 2013 8:08 am
by georg.merten
Hi,
meanwhile I wrote a function to refresh the anonymous program.
(it was not possible to refresh it from the user-session)
Code: Select all
function refreshIframe() {
var ifr = document.getElementsByName('mainFrame')[0];
ifr.src = ifr.src;
}
Thanks you for inspiration ;)
Re: Username in Anonymous-program - from userSpan ?
Posted: Thu Jun 27, 2013 10:55 am
by Scott Klement
The child frames is an array. So you'd have window.frame[0], window.frame[1], etc (depending on how many iFrames you have)
Does that help?
Re: Username in Anonymous-program - from userSpan ?
Posted: Thu Jun 27, 2013 11:10 am
by georg.merten
yes, thank you!