Skip to Content
author's profile photo Former Member
Former Member

URL of the current portal page loaded using Javascript ?

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 01, 2004 at 12:21 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      I got this class from Mr.Ron Hendrickx of SAP America.

      You will implement this method as part of your AbstractPortalComponent class.

      protected void doOnNodeReady(

      IPortalComponentRequest request,IEvent arg1) {

      //super.doOnNodeReady(request, arg1);

      NavigationEventsHelperService helperService =

      (NavigationEventsHelperService) PortalRuntime

      .getRuntimeResources()

      .getService("com.sap.portal.navigation.helperservice.navigation_events_helper");

      navTargetNode = helperService.getCurrentLaunchNavNode(request);

      request.getNode().putValue("navNode", navTargetNode);

      }

      The imports are ...

      import com.sapportals.portal.navigation.INavigationNode;

      import com.sapportals.portal.navigation.NavigationEventsHelperService;

      import com.sapportals.portal.prt.component.AbstractPortalComponent;

      import com.sapportals.portal.prt.component.IPortalComponentRequest;

      import com.sapportals.portal.prt.component.IPortalComponentResponse;

      import com.sapportals.portal.prt.pom.IEvent;

      import com.sapportals.portal.prt.runtime.PortalRuntime;

      The jar files are..

      com.sap.portal.navigation.helperserviceapi.jar

      com.sap.portal.navigation.serviceapi.jar

      This is one of the approaches (with Java). As suggested

      by others, youcan use Javascript also to achieve this.

      Hope this helps,

      Prasad Nutalapati

  • author's profile photo Former Member
    Former Member
    Posted on Sep 01, 2004 at 05:47 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 01, 2004 at 06:31 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 23, 2004 at 04:17 PM

    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
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.