Wednesday, December 3, 2014

Interportlet Communication using Public Render Parameters



Interportlet Communication using Public Render Parameters

Create two portlets named as PortletA and PortletB with classes PortletActionA, PortletActionB.

IN PortletA , do below things:
-----------------------------------
portlet.xml --> IN portlet configuration mention the below line :
<supported-public-render-parameter>firstName</supported-public-render-parameter>

after ending the portlet tag give the below lines:
 <public-render-parameter>
        <identifier>firstName</identifier>
          <qname xmlns:x="http://sun.com/params">x:firstName</qname>
    </public-render-parameter>
  

Repeat the above thing in PortletB also...


In Portlet A:-

PortletActionA Class:-

set the render parameter as below like:
public void portletAActionURL(ActionRequest actionRequest, ActionResponse actionResponse){

System.out.println("portletA callign");

actionResponse.setRenderParameter("firstName", "devi");
}


In PortletB :-


doview() method write below code:

String firstname =renderRequest.getParameter("firstName");

System.out.println("firstname == "+firstname);
renderRequest.setAttribute("firstname", firstname);



Then u will observe the value in your jsp as

renderRequest.getAttribute("firstName") and print this..

No comments:

Post a Comment