Multiple instances of the same portlet - Websphere

This is a discussion on Multiple instances of the same portlet - Websphere ; Hi, I'm a newbie to portlets so please forgive what I suspect to be a simple question. I have one portlet which I want to appear on two pages but running in different 'modes'. By modes I mean have a ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Multiple instances of the same portlet

  1. Multiple instances of the same portlet

    Hi,

    I'm a newbie to portlets so please forgive what I suspect to be a
    simple question.

    I have one portlet which I want to appear on two pages but running in
    different 'modes'. By modes I mean have a different value passed into
    it which determines the initial jsp is displayed.

    I've created two instances of my portlet & assigned one to each of my
    pages. The portlet's config page saves the initial setting using
    PortalPreferences :-

    String initialPage =
    request.getParameter("initialPage");
    String [] initialPageArray = new String[] {initialPage};
    PortletPreferences myPrefs = request.getPreferences();
    myPrefs.setValues("initialPage", initialPageArray);
    myPrefs.store();

    This appears to be working as I see a different setting when I go into
    the config page for each instance of the portlet.

    In the doView of my portlet-class I have the following code :-

    response.setContentType("text/html");
    PortletPreferences myPrefs = request.getPreferences();
    String initialPage = myPrefs.getValue("initialPage", "holdings");
    String page=request.getParameter("page");

    if (page == null){
    if(initialPage.equalsIgnoreCase("holdings")){
    page = "a.jsp";
    } else {
    page = "b.jsp";
    }
    }
    PortletRequestDispatcher rd =
    getPortletContext().getRequestDispatcher(page);
    rd.include(request, response);

    The problem is that even though I have two instances of the portlet
    they both always show the same initial page. In other words changing
    one of the instances config setting affects the behaviour of both
    instances, but changing the other instances config setting has no
    effect at all.

    Any ideas?

    Thanks.


  2. Re: Multiple instances of the same portlet

    Fixed it. Deleted all my portlet instances & created them again.
    Magically then worked.


+ Reply to Thread