Wednesday, November 30, 2011

Public render parameters

The JSR 286 portlet specification has introduced the Public render parameters concept: which allow portlets to share parameters with other portlets. That means we can achieve the Coordination between Portlets through the Public render parameters. Basically in JSR 168, the render parameters set in processAction is only available in the render of the same portlet. But in JSR 286 with the Public Render Parameters feature, the render parameters set in the processAction of one portlet will be available in render of other portlets also.
Following are the steps to create portlets that use the public render parameters:
Step-1. We will declare the render parameters to be shared in the portlet.xml file by setting the public render parameters at the portlet application level.
……

. . .


product-id

……
Step-2. Now specify the render parameter that the portlet would like to share in the portlet section.
……..

......
product-id


. . .
product-id

. . .

Strep-3 And now finally set the render parameter in the processAction() method:
public class ProductsPortlet extends GenericPortlet {
. . .
public void processAction(ActionRequest req, ActionResponse res) throws IOException, PortletException {
. . .
res.setRenderParameter("product-id", product);
}
. . .
}

Enjoy coding :-)

No comments: