Forum Stats

  • 3,851,977 Users
  • 2,264,055 Discussions
  • 7,904,923 Comments

Discussions

Trigger a custom event when a weblogic portal page is clicked

652669
652669 Member Posts: 8
edited Sep 12, 2008 11:45AM in WebLogic Portal
Hi,

I have created a portal which is running as desktop which has different pages configured in it. These pages are created by weblogic portal administration with portlets in it.I want to catch the page click event.So that i can trigger an event when a page is clicked which can be listened by the portlets within the page to do a custom action based on the event raised.

I have named the 3 tabs or pages as -

Page 1, Page 2, Page 3

Now when I click tab(page 2), I want to trigger a custom event. How to do it, i did not find any events related to this? Iam using Weblogic 8.1 sp6

Thanks
Ravi
Tagged:

Comments

  • 655221
    655221 Member Posts: 116
    Hi Ravi,
    There is a sample in the 8.1 docs that show how to dispatch a custom event when a page is visible and when it is visible and selected (active): http://edocs.bea.com/wlp/docs81/interaction/eventstracking.html#1028565
    http://edocs.bea.com/wlp/docs81/interm/src/sample_events.zip

    I think that the difference between what you want to do and what the sample in the docs does is this: you want to dispatch an event only when the page is first made active (when the menu link to it is clicked) but the sample dispatches the event every time the portal is rendered and that page is active.

    That sample doesn't do exactly what you want but it shows how to dispatch a custom event. Perhaps you could use a backing file on the page to dispatch your custom event: http://edocs.bea.com/wlp/docs81/ipcguide/backing.html#998982

    In the preRender() method of your page backing file you could figure out if the current request is for a page change to your page. If so, then fire the event. What you want is AbstractJspBacking.isRequestTargeted(): http://e-docs.bea.com/workshop/docs81/doc/en/portal/java-class/com/bea/netuix/servlets/controls/content/backing/AbstractJspBacking.html

    The isRequestTargeted() method will return true for a request that is a page change to your page.
  • 652669
    652669 Member Posts: 8
    Hi Thoefner,

    Thanks for providing the information related to the issue, i will check this.

    Thanks
    Ravi
  • 652669
    652669 Member Posts: 8
    Hi Thoefner,

    I went the information provided by you.I have question how can i configure a backing file for a page which is created through Portal Admin Console? since iam running my portal as desktop created in Portal Admin Console.The Portal desktop is run in streaming mode, in file-based mode( .portal ) we can specify backing file for the pages.

    Thanks
    Ravi
  • 655221
    655221 Member Posts: 116
    Hello Ravi,
    Here are a few options for adding a backing file reference to a page that is in your desktop. There are probably other possible solutions:

    1) Use the Export/Import utility to export the page into a .page file, edit it to add the backing file, and re-import the .page into the database. The Export/Import utility is sometimes referred to as the Xip tool: http://edocs.bea.com/wlp/docs81/prodOps/installation.html#1030830

    2) Create a page in Workshop with the backing file and create a dummy portal to contain it. Create a dummy desktop using your dummy .portal. This makes the page available in the admin tools for use in your other desktops. Add this page to your desktop and use it instead of a non-backing file page.
  • 653103
    653103 Member Posts: 114
    edited Aug 21, 2008 12:23PM
    is ther a way to listen the events in portlets content, for example when the user clicks some link, or how would you update the content in a portlet from other, like i do the request but response is for you. And is this posible using content presenter portlet???

    Message was edited by:
    soker
  • 652669
    652669 Member Posts: 8
    edited Aug 24, 2008 4:30AM
    Hi Thoefner,

    the links you provided are very informative . I will use this to solve my issue.

    Thanks
    Ravi

    Edited by: ravin4u on Aug 24, 2008 2:00 PM
  • 652669
    652669 Member Posts: 8
    edited Sep 12, 2008 3:55AM
    Hi Thoefner,

    I implemented backing file(MyPageBacking.java) for the page "MyPage" and used it in my desktop. But it is not working as expected for the page click below is the code

    public class MyPageBacking extends AbstractJspBacking {

    public boolean preRender(HttpServletRequest request, HttpServletResponse response) {
    PortletBackingContext context = PortletBackingContext.getPortletBackingContext(request);
    HttpSession session = request.getSession();
    if(isRequestTargeted(request)){
    System.out.println("The Page is clicked.");
    context.fireCustomEvent("PageClickEvent","clicked");
    }else{
    System.out.println("The Page is not clicked.");
    context.fireCustomEvent("PageNotClickEvent","notClicked");
    }
    return true;
    }
    }

    The isRequestTargeted() is not getting called for page click but gets called randomly sometime when there is some action in the portlets within the page "MyPage". Is the above implementation is correct for the page having backing file?

    Thanks
    Ravi

    Edited by: ravin4u on Sep 12, 2008 1:20 PM

    Edited by: ravin4u on Sep 12, 2008 1:22 PM

    Edited by: ravin4u on Sep 12, 2008 1:23 PM

    Edited by: ravin4u on Sep 12, 2008 1:25 PM
  • 650850
    650850 Member Posts: 843
    Hello,

    The problem appears to be that you are trying to determine if the portlet was targeted and to send events in preRender()-- this should be done in your backing file's handlePostbackData() method. Some of the earlier links and examples on this discussion thread mixed up "campaign events" with "interportlet events"-- they are two different things. The information about inter-portlet events is located at http://edocs.bea.com/wlp/docs81/ipcguide/overview.html .

    Interportlet events can only be sent during the handlePostbackData() backing file lifecycle phase, or when handling another incoming event. If an event is sent during preRender() it may not be delivered to any other portlets, and in later versions of WLP it will actually result in an error being logged.

    So your backing file should probably look something like this:

    import com.bea.netuix.servlets.controls.content.backing.AbstractJspBacking;
    import com.bea.netuix.servlets.controls.portlet.backing.PortletBackingContext;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    /**
    * Sample backing file for sending an event when the portlet
    * is clicked.
    */
    public class SampleBacking extends AbstractJspBacking
    {
    public boolean handlePostbackData(HttpServletRequest request,
    HttpServletResponse response)
    {
    // Determine if this request originated due to an action
    // on our portlet
    if(isRequestTargeted(request))
    {
    PortletBackingContext context = PortletBackingContext.getPortletBackingContext(request);
    context.fireCustomEvent("portletClicked", "my portlet was clicked");
    }

    return false;
    }

    }
This discussion has been closed.