Inter Portlet Communication : Public Render Parameters

This post is on Public Render Parameters (PRP) in portlets in IBM WebSphere portal 8 using RAD.

Important Points:

  • Declare events in its deployment descriptor (Portlet.xml) by using <public-render-parameter> element in portlet application section.
  • In portlet section each portlet that supports it declare it by <supported-public-render-parameter> element.
  • The portlet sets PRP in processAction on the PRP identifier.
  • Portlets can read PRP in there render phase.
  • We can limit the scope of PRP by setting param.sharing.scope in advance property of pages in IBM portal.

In our sample (similar to events example), we will have two portlets in differents wars.

Application 1:  PrpApp1

  • Create a Portlet project PrpApp1. In the wizard, create a portlet and check to create a custom portlet class. You can add custom class afterward also, by creating a class extending FacesPortlet and making an entry in portlet.xml.
  • Make your manage beans accordingly. I made a simple Action/Form classes.
  • My page only contains a dropdown with fixed city list, on change of which a JS is called that submits a page.
  • Following is the portlet.xml for PrpApp1:
    PrpPortlet1XMLNote the Identifier and the Name attributes.
  • Go to your custom portlet class for this portlet. You can set event in the processAction method as follow:
    PrpPorlet1ProcessActionNote that we set the PRP on the Identifier. Here selectCityForm is my manage bean.

Application 2:  PrpApp2

  • Create a Portlet project PrpApp2. In the wizard, create a portlet and check to create a custom portlet class.
  • Make your manage beans accordingly. I created only a Form bean.
  • Following is the portlet.xml for PrpApp2:
    PrpPortlet2XMLNote the Identifier and the Name.
    Since we are using PRP which is setted by different portlet, we have to use custom namespace of that portlet with the name (not identifier) of the PRP.
  • Go to your custom portlet class for this portlet. You can set event in the doView method as follow:
    PrpPortlet2DoView

    Here productForm is my manage bean.

Deploy both application. Add them on different pages and TEST!!

Limiting the sharing scope for public render parameters:

In some senarios, you may not want to share your PRP to everyone. In IBM portal, you can have control over this by param.sharing.scope parameters.

Go to Page properties > Advance Options > I want to set parameters

Add  param.sharing.scope parameter with a value.

ParamSharingScope

If two pages have same param.sharing.scope value, then only they can share PRP.

ALL Done. Hope it helps!!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: