Sun Java System Portal Server 7.2 Developer's Guide

ProcedureTo Create Portlets That use the Public Render Parameters

  1. Declare the render parameters to be shared in the portlet.xml file by setting the public render parameters at the portlet application level.


    <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/
                 portlet-app_2_0.xsd"             
                 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"
                    
    
    id="myPortletApp" version="2.0">
    	<portlet>
    	...
    	</portlet>
    
    	<public-render-parameter>
    		<identifier>zip-id</identifier>
    		<qname xmlns:x="http://sun.com/params">x:zip</qname>
    	</public-render-parameter>
    
    </portlet-app>
  2. Specify the render parameter that the portlet would like to share in the portlet section.


    <portlet-app_2_0.xsd"
    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
    
    id="myPortletApp" version="2.0"
    <portlet>
    		<description>WeatherPortlet</description>
    		<portlet-name>WeatherPortlet</portlet-name>
    		<display-name>WeatherPortlet</display-name>
    		<portlet-class>com.sun.portal.portlet.WeatherPortlet</portlet-class>
    		<supported-public-render-parameter>zip-id<//supported-public-
       	render-parameter>
    <portlet>
    
    <portlet>
    		<description>MapPortlet</description>
    		<portlet-name>MapPortlet</portlet-name>
    		<display-name>MapPortlet</display-name>
    		<portlet-class>com.sun.portal.portlet.MapPortlet</portlet-class>
    		<supported-public-render-parameter>zip-id<//supported-public-
       	render-parameter>
    <portlet>
    		...
    <portlet-app>
  3. Set the render parameter in the processAction() method by using the defined public render parameter identifier as the key.


    public class WeatherPortlet extends GenericPortlet {
         . . . 
       public void processAction(ActionRequest req, ActionResponse res)
       throws IOException, PortletException {
        . . . 
               res.setRenderParameter("zip-id", zip);
         }
         . . .
    }