Hello:
I am trying to add programmatically the url of the current
page loaded in the portal to the 'Favorites List'. There
is a pre-built KM iview to store your 'favorites'.
I can extract and write to this 'favorites' using KM java
API. But only challenge is to extract the current loaded
page URL and title using Javascript.
I would appreciate any help in this regard.
Thank you very much,
Prasad Nutalapati
or if the breadcrumb is not available, or you want to do it on the serverside instead of javascript, you can use the NavigationEventsHelperService to get the launchurl (of the page) after the POM node is loaded.
I'll send you an email with an example.
For the current page url you can use window.location
The title is alot more difficult. Perhaps you can do it with a javascript DOM browser (http://javascript.internet.com/page-details/dom-browser.html) by searching for the
Hi,
I you are having the standard BreadCrumb in your Portal Desktop, then you can use various methods/variables available in the HistoryFramwork.js
For example to simply find the URL, Title of the current loaded Page you can use, the following code snippet in your iView.
index = top.gHistoryFrameworkObj.GetActiveTrackingEntryIndex();
name = top.gHistoryFrameworkObj.TrackingEntries.TrackingStackContainer[index].title
url = top.gHistoryFrameworkObj.TrackingEntries.TrackingStackContainer[index].URL
Hope this helps.
Thanks
Ankur
Dude i was having the exact same problem. I solved it using the SAP-provided EPCM (javascript client framework).
/*********************
Javascript Code
*
********************/
var pageName = "";
var URL = "";
function bookmarkPage()
{
/* page url */
var fullURL = "https://<%=request.getServerName()%>/irj/portal?NavigationTarget=" + URL;
/* IE bookmark */
if(EPCM.getUAType() == EPCM.MSIE)
{
window.external.AddFavorite(fullURL , pageName);
}
else
{
var msg = "Sorry. The \"Add To Favorites\" feature only works with Internet Explorer. " +
"The URL to this page is " + fullURL;
alert(msg);
}
}
/* get pagename from eventObject from subscribed event */
function getPageObject(eventObj) {
pageName = eventObj.dataObject.title;
URL = eventObj.dataObject.URL;
}
/* subscribe to event in pagetoolbar area */
EPCM.subscribeEvent("urn:com.sapportals:navigation", "AddNavTargetAllowDuplicate", getPageObject);
/*****************
End of code
*
****************/
Basically, what this does is that everytime a page loads, the innerpage, where the content is, raises an event using the EPCM.raiseEvent() method. EPCM.subscribeEvent subscribes to an event called AddNavTargetAllowDuplicate which has an object holding the page information (i.e. page title and URL (ROLE://...)). Everytime that it notices an event raised, the function getPageObject gets called to go get data from the event object that is available globally in the framework.
You should be able to put this code anywhere in any iview and it should work. Thou i have only tried putting it in the masthead. Try and if you still have questions please let me know.
Add a comment