Public Render Parameter

The JSR 286 specification introduces concept of Public Render paramter which are same as the render paramter before with a differnece that they can be shared across portlets. Your portlet code for setting render parameter in the URL and reading it remains same, only difference is you declare a render parameter in the portlet.xml and then they are shared across different portlets

I built two sample portlet one is WeatherPortlet and other is MapPortlet, they do nothing but set zip as render parameter and read zip parameter and display it in view mode, this is how my WeatherPorltet looks like

public class WeatherPortlet extends GenericPortlet{
protected void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
System.out.println("Entering WeatherPortlet.doView()");
response.setContentType("text/html");
response.getWriter().println("Value of zip render parameter " +

request.getParameter("zip"));
PortletURL sfoWeather = response.createRenderURL();
sfoWeather.setParameter("zip", "94101");
response.getWriter().println("<a href='"+ sfoWeather.toString()+"'>SFO</a>");

PortletURL puneWeather = response.createRenderURL();
puneWeather.setParameter("zip", "411007");
response.getWriter().println("<a href='"+
puneWeather.toString()+"'>Pune</a>");
System.out.println("Exiting WeatherPortlet.doView()");
}
}


The MapPortlet is same as that of the WeatherPortlet. Now the next part is in the portlet.xml i declare zip as public render parameter and now if i set zip parameter in map it gets available to weather and other way round


<?xml version="1.0" encoding="UTF-8"?>
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd
http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
<portlet>
<portlet-name>WeatherPortlet</portlet-name>
<display-name>Weather Portlet</display-name>
<portlet-class>com.webspherenotes.jsr286.WeatherPortlet</portlet-class>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
</supports>
<portlet-info>
<title>Weather Portlet</title>
<short-title>Weather Portlet</short-title>
<keywords>WeatherPortlet</keywords>
</portlet-info>
<supported-public-render-parameter>zip</supported-public-render-parameter>
</portlet>
<portlet>
<portlet-name>MapPortlet</portlet-name>
<display-name>MapPortlet Portlet</display-name>
<portlet-class>com.webspherenotes.jsr286.MapPortlet</portlet-class>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
</supports>
<portlet-info>
<title>MapPortlet Portlet</title>
<short-title>MapPortlet Portlet</short-title>
<keywords>MapPortletPortlet</keywords>
</portlet-info>
<supported-public-render-parameter>zip</supported-public-render-parameter>
</portlet>

<public-render-parameter>
<identifier>zip</identifier>
<qname xmlns:x="http://webspherenotes.com/params">x:zip</qname>
</public-render-parameter>

</portlet-app>


In WebSphere once you set zip render parameter it remains in the URL until you logout and login again, if you add the Weather and Map portlet on different pages then zip code set on one page is available on other

4 comments:

Anonymous said...

Hi,
Can you please tell what is the scope of public render parameter? Is it session scope or request scope?

srjwebsolutions said...


We are leading responsive website designing and development company in Noida.
We are offering mobile friendly responsive website designing, website development, e-commerce website, seo service and sem services in Noida.

Responsive Website Designing Company in Noida
Website Designing Company in Noida
SEO Services in Noida
SMO Services in Noida

Vikas Chaudhary said...

Battery Mantra is Authorized exide car battery dealer in Noida and Greater Noida. We are providing our service in Indirapuram, Delhi, Ashok Nagar.

Exide Battery Dealer in Noida
Battery Dealer in Noida
Authorized Battery Dealer in Noida
Car Battery Dealer in Noida
Car Battery Dealer
Exide Battery Dealer

EG MEDI said...

Egmedi.com is online medical store pharmacy in laxmi nagar Delhi. You can Order prescription/OTC medicines online.
Cash on Delivery available. Free Home Delivery


Online Pharmacy in Delhi
Buy Online medicine in Delhi
Online Pharmacy in laxmi nagar
Buy Online medicine in laxmi nagar
Onine Medical Store in Delhi
Online Medical store in laxmi nagar
Online medicine store in delhi
online medicine store in laxmi nagar
Purchase Medicine Online
Online Pharmacy India
Online Medical Store