on 05-03-2016 12:12 PM
Scenario:
I am launching different Personas transactions from a UI5 based home page. From UI5, I am calling various transactions using ~transaction parameter in the URL. This approach works well but has one disadvantage. Whenever I call a new URL(transaction), it takes 3 to 4 seconds to load the entire page/transaction. Calling a transaction using session.callTransaction is much faster. (within a second). So I want to skip loading the entire page.
So my approach is to use URL hash and pass Tcode to Personas environment. Ex: /sap/bc/personas?#IW32.
URL hashes do not cause the page to reload. Then capture the hash value within personas scripting and then to call session.callTransaction.
In the screen load event, I called the below function.
window.onhashchange = function(){ alert('hi'); };
Problem:
I see that above event registration does not work, though it does not give any error. Upon changing the hash, callback function does not get triggered.
I tried entering the above code in the browser console, ( after the entire page loaded.) That worked without any issue.
Question:
Is there a way to do proper event registration for window object within personas events?
Any comments are welcome.
Regards
Krishna
Hello Krishna,
that's an intiguing problem.
Your onhashchange handler is not called because you have to attach it to the outmost window.
From a personas script perspective this is the "parent"-window. So this worked for me when executed as a personas script, e.g. as onLoad or onClick.
parent.onhashchange= function(ev){
var sTransactionName = ev.newURL.substring(ev.newURL.indexOf("#")+1);
session.startTransaction(sTransactionName);
sap.personas.scripting.executeScriptInternal({src: ''}); // this is needed to refresh the screen.
};
The other option avoiding having to register a callback is to call the following from your UI5 page:
<personaswindow>.frame[0].sap.personas.scripting.executeScriptInternal({src: 'session.startTransaction("'+sTransactionName+'");'});
The potential problems with this approach are:
1) Cross scripting issues may occur if your UI5 page and personas are not in the same domain.
2) You have to access the right frame, the one that has the method sap.personas.scripting.executeScriptInternal(), which should be frame[0] from the personas main window.
Best Regards,
Clemens
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Clemens,
thanks a lot for the valuable information. I am encountering a problem though.
When I run Personas in a browser, I am able to navigate to different transactions by changing the hash. So no issues there. (I used the first approach).
But when I launch it from UI5, I show Personas in an iframe. Upon UI5 events, I change the src of the iframe using something like this.
$('#webguiFrame').prop("src", "/sap/bc/personas?sap-client=200#IK34"); This is resulting in an error in Personas framework code.
It looks like window is null, when lauched from an iframe.
Any suggestions please?
Regards
Krishna
Hi,
the trick is to find the right window and to set the window's document.location.hash property.
This is my script to start the change the hash in the embedded iframe:
var frame = $("#<iframeid>");
frame.context.location.hash="SE11"; //frame is jquery wrapper and frame.context is the frame's document
Cheers,
Clemens
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.