Search code examples
jsf-2portletwebsphere-portaljsr286

Portlet aware of other portlets on the same page


i am tasked to develop an "action portlet" that contains the actions (e.g. h:commandLink) for all other portlets on the same page. Now these actions should only be available if the corresponding portlet is actually present on the same page.

Is it possible for a portlet to "know" which other portlets are on the same page without having to process an ActionRequest first?

Greetings.


Solution

  • My gut reaction to your question is that a portlet should be self contained enough that it doesn't need other portlets on the page to function. So without any other knowledge of why this needs to be done, it sounds like this design choice has some inherent flaws. Portlet A should never need to process ActionRequests for Portlet B. It seems like you're just trying to bend, break and abuse the portlet spec but I'll admit I've broken design rules when the use case warrants it.

    As an alternative, I might suggest instead that your portlet allow other portlets to tell your portlet what they need done rather than your portlet having to ask. You could do this client-side where each other portlet runs a little JavaScript on page load to inform your portlet what it needs to do.

    Back to your actual question. I haven't dug too deep into the documentation but, there is an API provided by WebSphere Portal that may help determine what you need. Below is the link to IBM's documentation on the subject.

    http://www-01.ibm.com/support/knowledgecenter/SSHRKX_8.5.0/mp/dev/dgn_modelovw.dita

    The Model SPI is how a portlet can access everything about the page structure of the portal, the navigation state and a number of other related things. I would expect the Model SPI to be able to tell you what other portlets are on the same page as your current portlet. Once you get a list of other portlets on the page, it would be up to you how to determine what other links you need to render.