JSR286 : Public Render Parameter feature (updated)

When the Java Portlet Specification(JSR 286) early draft was released last year, i had written a blog on Public Render Parameter feature. Recently the proposed final draft was released, it has some changes in public render parameter feature. In this blog i will explain the feature with an example.

In JSR 168, the render parameters set in processAction is only available in the render of the same portlet.

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. Using public render parameters instead of events avoids the additional process event call.

In order to allow coordination of render parameters with other portlets, within the same portlet application or across portlet applications, the portlet can declare public render parameters in its deployment descriptor using the public-render-parameter element in the portlet application section. Public render parameters can be viewed and changed by other portlets or components.

In the portlet section each portlet can specify the public render parameters it would like to share via the supported-public-render-parameter element. The supported-public-render-parameter element must reference the identifier of a public render parameter defined in the portlet application section in a public-render-parameter element.

In the code, the portlets should use the defined public render parameter identifier to access the public render parameter(new addition in the proposed final draft).

To create portlets that use the public render parameters, follow these steps(snippets from WeatherMap sample application):

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 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>
         <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:

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

You can download the binary WeatherMap.war file to deploy and run the sample application in OpenPortal Portlet Container 2.0 Beta2 (or latest). You can also get the source for the sample. If you are behind a firewall you need need to set the proxy in the webcontainer configuration.

The figure shows the Weather and Map portlets. The Weather portlet sets the zip-id which is declared as a Public Render Parameter. This parameter is supported by both Weather and Map portlets. Any change in the value of zip by Weather portlet is reflected during the render phase of both weather and map portlets.

Weather Map Sample 

Comments:

asdadqargf

Posted by asd on September 08, 2008 at 05:51 AM IST #

Can Public Render Parameter support be used in JSF portlet?

Posted by Franky on October 06, 2008 at 08:04 AM IST #

Yes you can. But for that you need to set a config parameter in the portlet.xml(https://jsfportletbridge.dev.java.net/issues/show_bug.cgi?id=30). By doing so render parameters are available and if deployed in OpenPortal Portlet Container 2.0, other jsf portlets will also get the parameter. Let me know if you face any problems.

Posted by Deepak Gothe on October 06, 2008 at 08:49 AM IST #

Hi Deepak,

I'm using the public render parameters since a few days (in Liferay) and I came across a thing which I don't understand.

In which portlet app should the param be defined (the public-render-parameter element)? In the one which reads the param or the one which sets the param at the response?

I was pretty sure that I should do that on the portlet which sets the param but it only seems to work in Liferay when I define the param in the consuming portlet.

Posted by Rob Sonke on October 08, 2008 at 06:52 AM IST #

Hi Rob,
Unlike Eventing where there is specific element for processing and publishing, for Public Render Parameters, the same element is used for both set/get. Is your question related to two portlet apps... If one portlet app wants to set and other portlet app wants to receive then the definition should be in both.

Posted by Deepak Gothe on October 09, 2008 at 05:15 AM IST #

Ah that explains it. We're using two portletapps right, loaded as plugins with a different portlet.xml

Thanks for your answer.

Posted by Rob Sonke on October 09, 2008 at 05:19 AM IST #

Related to getting this working in JSF, can you please explain more what you mean by config parameter in portlet.xml ?

Drop a line or two of example. (Using Liferay + Tomcat)

Posted by Petar on October 15, 2008 at 10:04 PM IST #

I will try blog about it with an example sometime by the end of this week.
Meanwhile..
Suppose you want share the parameter "param1".
1. You need to add the following to your portlet.xml

<init-param>
<name>com.sun.faces.portlet.SAVE_REQUEST_SCOPE</name>
<value>true</value>
</init-param>

2. And you need to add public render parameter definition for param1 in the portlet.xml.

Posted by guest on October 16, 2008 at 02:52 AM IST #

I have blogged about the support for public render parameter in jsf portlet. You can check the blog - http://blogs.sun.com/deepakg/entry/jsf_portlet_and_public_render

Posted by Deepak Gothe on October 19, 2008 at 04:56 PM IST #

I am investigating whether sun FacesPortlet class would allow this or I need to subclass. Any hints?

What are the chances that this mod enters specification?

I could show you my current work related, I would be gratefull if you contact me.

Posted by Amy on November 07, 2008 at 11:06 AM IST #

As mentioned in the blog ( http://blogs.sun.com/deepakg/entry/jsf_portlet_and_public_render ), the current jsf portlet bridge 1.2.3 does support public render parameter. You can send a mail about you work to dev@jsfportletbridge.dev.java.net . Thanks.

Posted by Deepak Gothe on November 07, 2008 at 04:59 PM IST #

I am trying to use the public render parameters as explained above, It does not work. Here is what i want I wanted to retrieve a parameter set in the url on page for all portlets during the doView() method. How can get the query params set in the url in the doView() method, so that I can use that in the portlets that wanted to use that param in a page. For eg: I want to get the info of a person using the id passed and wanted to use that in 5 portlets on a page although there are 10 portlets on that page.

As per your blog it should be possible. but it does not work.. Any thoughts

THanks

Posted by satya on January 13, 2009 at 10:31 PM IST #

What you want is access to query parameters..right? Looks like the issue https://portlet-container.dev.java.net/issues/show_bug.cgi?id=160 . This should be available in the next release of Portlet Container.

Posted by Deepak on January 19, 2009 at 06:53 AM IST #

Hi all, I'm using the public render parameters since a few days (in Liferay), but it does not work for me, the only one difference with the examples is that i use a class to do the doView, i'm not use jsp's, i have to do something else for use public render parameters????

Posted by Julián Poveda on January 24, 2009 at 07:33 PM IST #

Hi, using public render parameters in either doView or JSPs is the same. Does your application work on OpenPortal Portlet Container? In Liferay you need to add the following property to portal-ext.properties.Setting this property allows Liferay to use OpenPortal Portlet Container implementation.

portlet.container.impl=sun

Posted by Deepak on January 27, 2009 at 02:58 AM IST #

Hi Deepak,
Can I use this feature in Liferay (Version - 5.2.2). I have deployed these portlets. Simplified above portlets just to print the received zip-id. But the portlets are unable to access the parameter specified in the url (http://server:8080/web/guest/sample?zip-id=200). Or am I missing some thing?

Posted by Ganesh Gembali on March 30, 2009 at 10:31 AM IST #

Hi Ganesh,
You are trying to send the portal query parameter and expecting the portlet to read it. Portlet cannot access the portal query parameters. In your portlet if you access request.getParameter("zip-id"), it will return null. But this can be handled by adding the following in sun-portlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<portlet-app-extension xmlns="http://www.sun.com/software/xml/ns/portal_server"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sunportal="http://www.sun.com/software/xml/ns/portal_server"
xsi:noNamespaceSchemaLocation="http://www.sun.com/software/xml/ns/portal_server"
version="2.0">

<portlet>
<portlet-name>your-portlet-name-same-as-in-portlet.xml</portlet-name>
<portal-query-parameters>
<name>zip-id</name>
</portal-query-parameters>
</portlet>
</portlet-app-extension>

In order to use OpenPortal Portlet Container implementation in Liferay, set the below property in portal-ext.properties and redeploy the portlet wars.

portlet.container.impl=sun

Posted by Deepak Gothe on March 30, 2009 at 11:13 AM IST #

I am using LR5.1.1 version.

I am trying to communicate between existing portlet and custom portlet using the example given by You.
communication between 2 custom portlets is working using <public-render-parameter>
But communication between exisitng portlet(Eg:Journal_Articles) and custom portlet using <public-render-parameter> is not working

Posted by Swarna on April 23, 2009 at 07:03 AM IST #

Most of the existing portlets do not support public render parameters OOTB. If you look at portlet-custom.xml in liferay portal webapp, you will see that they do not have supported-public-render-parameter tag. Hence its not working.

Posted by Deepak Gothe on April 24, 2009 at 04:37 AM IST #

Hi Deepak,
I read your blogs about IPC 286, and they are all well written. I am new to portal development and am having a situation where I have to redirect to a different portlet on button click and also carry the parameters in a session, say name and description from the first portlet to the second one. Both these portlets are in the same war file. I don't think Public render feature will be helpful in my case. Can you please tell me if I can find any tutorials for a similar situation?

Thanks

Posted by laxmi on May 01, 2009 at 04:45 PM IST #

Hi,
Can you clarify few things..when you say redirect from first portlet to second portlet are you saying that the second portlet should replace the first portlet after button click. Why do you want to carry the parameters in a session. If you want to carry name and description from first portlet to the second portlet you can use public render parameter. Why do you think public render parameter will not be helpful in your case?

Regards,
Deepak

Posted by Deepak Gothe on May 02, 2009 at 09:17 AM IST #

Hi Deepak,
Iam using the Liferay5.2 with netbeans and i want to use public render parameter.but iam getting the null values.I have written like this

<portlet>
<portlet-name>Publisher</portlet-name>
<portlet-class>
com.test.Sender
</portlet-class>
<portlet-info>
<title>Publisher
</title>
<short-title>Publisher
</short-title>
</portlet-info>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>VIEW</portlet-mode>
</supports>
<supported-public-render-parameter>
myname
</supported-public-render-parameter>
<supported-locale>en</supported-locale>
</portlet>

<portlet>
<portlet-name>Receiver
</portlet-name>
<portlet-class>
com.test.Receiver

</portlet-class>
<portlet-info>
<title> Receiver
</title>
<short-title> Receiver
</short-title>
</portlet-info>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>VIEW</portlet-mode>
</supports>
<supported-public-render-parameter>
myname
</supported-public-render-parameter>
<supported-locale>en</supported-locale>
</portlet>

<public-render-parameter>
<identifier>myname</identifier>
<qname xmlns:x="http://www.liferay.com/public-render-parameters">x:public-render-param</qname>
</public-render-parameter>

Sender.java

public class Sender extends GenericPortlet {

. . . . . .

public void processAction(ActionRequest actionRequest,

ActionResponse actionResponse) throws PortletException, IOException {

String myname = actionRequest.getParameter("myname");

actionResponse.setRenderParameter("myname", myname);

}

public void doview(RenderRequest renderRequest,

RenderResponse renderResponse) throws PortletException, IOException {

PortletRequestDispatcher portletRequestDispatcher = portletConfig

.getPortletContext().getRequestDispatcher(

"/WEB-INF/jsp/view.jsp");

portletRequestDispatcher.include(renderRequest, renderResponse);

}

. . . . .

}

Receiver.java

public class Receiver extends GenericPortlet {

. . . . .

public void doview(RenderRequest renderRequest,

RenderResponse renderResponse) throws PortletException, IOException {

PortletRequestDispatcher portletRequestDispatcher = portletConfig

.getPortletContext()

.getRequestDispatcher(

"/WEB-INF/jsp/showParameter.jsp");

portletRequestDispatcher.include(renderRequest, renderResponse);

}

view.jsp

<%@taglib prefix="portlet" uri="http://java.sun.com/portlet_2_0"%>

<portlet:defineObjects />

<form action="<portlet:actionURL/>" name="form" method="post">

<input type="text" name="myname"> <input type="submit" value="submit">

</form>

showParameter.jsp

<%@taglib prefix="portlet" uri="http://java.sun.com/portlet_2_0"%>

<portlet:defineObjects />

<%=renderRequest.getParameter("myname")%>

Iam using the netbeans please can u say me what is the wrong here
waitng for ur helppppppp

Posted by Srinivas on June 03, 2009 at 08:56 AM IST #

The code snippet looks ok. What is the webcontainer? Do you see any exceptions?
Can you try with Sun Portlet Container. You can do that by adding portal-ext.properties to WEB-INF/classes of liferay-portal webapp and setting the property portlet.container.impl=sun. You need to redeploy the webapp after restarting liferay.

Posted by Deepak on June 03, 2009 at 09:18 AM IST #

Hi Deepak,
iam using Liferay Portal Server 5.1.x/5.2.x with glassfishv2
and i didnot find the sun-portal.xml file also
and in web\\WEB-INF
ihave only liferay-display.xml
liferay-plugin-package.properties
liferay-portlet.xml
portlet.xml
web.xml
and in the liferay-plugin-package.properties i have this code
#liferay-plugin-package.properties
#Tue Jun 02 18:37:21 CEST 2009
portal.dependency.jars=commons-logging.jar
tags=portlet

so i should add sun-portal.xml and port-ext.properties to it
please can you help for thissss

and when i tried this example in opencontainer it worked for me

Posted by Srinivas on June 03, 2009 at 10:00 AM IST #

Create a file called "portal-ext.properties" and add the following line in it.

portlet.container.impl=sun

Copy this file to domains/domain1/applications/j2ee-modules/liferay-portal/WEB-INF/classes. Then restart liferay. After this is done, you need to redeploy the the portlet.

Posted by Deepak on June 03, 2009 at 10:07 AM IST #

Hi Deepak,
C:\\liferayportalGF522\\glassfish\\domains\\domain1\\applications\\liferay-portal\\WEB-INF\\classes\\portal-ext.properties

is already existed here so i copied this line

portlet.container.impl=sun

and restarted the server.But still iam geeting nullvalue only so i should add any more new thing to it.But i did not create sun-portal.xml file in my project

Eagrly waiting for ur reply

Posted by Srinivas on June 03, 2009 at 03:11 PM IST #

There is no need to add sun-portlet.xml . Did you redeploy the portlet war after restarting the server?

Posted by Deepak on June 03, 2009 at 03:29 PM IST #

Hi Deepak,

i just redployed the war file again.but in my container it is saying that the war file is undeployed .

So please can you say step by step to do this in liferay.

Posted by Srinivas on June 03, 2009 at 04:40 PM IST #

Can you send your NB project to users@portlet-container.dev.java.net? Thanks. I will quickly try and give you step by step info.

Posted by Deepak on June 04, 2009 at 03:21 AM IST #

Hi Deepak,
I have Posted the project to ur Email

Posted by Srinivas on June 04, 2009 at 07:21 AM IST #

Did you try the PortalSR.war on OpenPortletContainer 2.1? The portlet.xml is not according to the portlet 2.0 schema. When you deploy on OpenPortletContainer 2.1, it will immediately tell you that its not according to XSD. In case of Liferay, you need to check the server logs. You will see that there is an exception "Invalid content was found....". The <supported-public-render-parameter> should be after </portlet-info> tag in both PortalS and PortalR. Make this change and your portlet will start working.

Posted by Deepak on June 04, 2009 at 10:03 AM IST #

Hi Deepak,
Thanks For ur Help,I got the answer and iam very much pleased by ur replies.
can i contact u if i have any more doubts regarding liferay.

Posted by srinivas on June 04, 2009 at 10:44 AM IST #

Good to know that it worked for you. If you are facing problems using Webspace Server you can send a mail to users@webspace.dev.java.net , if you faces problems using Liferay you can pose queries in Liferay forums. Your queries and our responses will be help others in the community who face similar problems.

Posted by Deepak on June 04, 2009 at 10:59 AM IST #

Hi Deepak,
I have one more doubt regarding this .Now iam communicating the portlet form one to another .my simple doubt is that can i communicate means can i redirect form one portal page to another.with these communications i am staying only in one page.From my portlet publisher i want to redirect to portlet receiver can this possible using the renderparameter .if u have any please can u post

Posted by srinivas on June 09, 2009 at 02:46 PM IST #

From the portlet publisher if you want to invoke sendRedirect, this can happen in processAction , but it will be action parameters and not render parameters.

Posted by Deepak on June 10, 2009 at 06:13 AM IST #

Hi Deepak,
Can you give me an example for the sendRedirect

Posted by srinivas on June 10, 2009 at 10:30 AM IST #

Hi Deepak,

I have a query regarding the usage of Public Render Parameter, in one of the requirement,

Background:

I have a portal page which contains multiple portlets .

When Page loads ., all portlets tries to get the information from back-end. If any portlet encounters serious exception.,the other portlet has to be communicated ., so that second-portlet render the error message.!

Can we use public render parameter here..? or do we need to use diff mechanism ?

Please note that: This should happen on page load. , there is no explicit user-action involved.

Posted by Karnam on June 27, 2009 at 07:39 PM IST #

Hi Deepak,

I have a query regarding the usage of Public Render Parameter, in one of the requirement,

Background:

I have a portal page which contains multiple portlets .

When Page loads ., all portlets tries to get the information from back-end. If any portlet encounters serious exception.,the other portlet has to be communicated ., so that second-portlet render the error message.!

Can we use public render parameter here..? or do we need to use diff mechanism ?

Please note that: This should happen on page load. , there is no explicit user-action involved.

Posted by Karnam on June 27, 2009 at 07:52 PM IST #

When the portlet encounters serious exception how does it update the portlet? If a renderURL targetted to a portlet has a public render parameter, then all portlets interested in that will be updated.

Posted by Deepak on June 29, 2009 at 04:56 AM IST #

Hi Deepak, i now working on LR 5.2.2, i need to pass parameter from portlet A to portlet B in same page,
but portlet B seem renderRequest.getParameter('blah') is return null,

<portlet>
<portlet-name>category</portlet-name>
<display-name>Category</display-name>
<portlet-class>com.liferay.portlet.StrutsPortlet</portlet-class>
<init-param>
<name>view-action</name>
<value>/ext/category/view</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>edit</portlet-mode>
</supports>
<resource-bundle>com.liferay.portlet.StrutsResourceBundle</resource-bundle>
<supported-public-render-parameter>categoryId</supported-public-render-parameter>
</portlet>
<portlet>
<portlet-name>list</portlet-name>
<display-name>Listing</display-name>
<portlet-class>com.liferay.portlet.StrutsPortlet</portlet-class>
<init-param>
<name>view-action</name>
<value>/ext/listing/view</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>edit</portlet-mode>
</supports>
<resource-bundle>com.liferay.portlet.StrutsResourceBundle</resource-bundle>
<supported-public-render-parameter>categoryId</supported-public-render-parameter>
</portlet>
<public-render-parameter>
<identifier>categoryId</identifier>
<qname xmlns:x="http://www.liferay.com/public-render-parameters">x:categoryId</qname>
</public-render-parameter>

this is my portlet-ext.xml,

how to set the parameter so that portlet can get the value ?
i am using rendering

my class is extend com.liferay.portal.struts.PortletAction

thanks

Posted by chiochuan on July 13, 2009 at 05:08 AM IST #

You should set render parameter in processAction method. You need to override the processAction method of com.liferay.portal.struts.PortletAction

Posted by Deepak on July 13, 2009 at 05:27 AM IST #

Hi

i have override the processAction

sender java file

public class CategoryViewAction extends PortletAction {

public void processAction(
ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
ActionRequest actionRequest, ActionResponse actionResponse)
throws Exception {

String categoryId = actionRequest.getParameter("categoryId");
actionResponse.setRenderParameter("categoryId", categoryId);
}
}

receiver java file

public class ListViewAction extends PortletAction {

public ActionForward render(
ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
RenderRequest renderRequest, RenderResponse renderResponse)
throws Exception {

System.out.println("categoryId " +
renderRequest.getParameter("categoryId"));

return mapping.findForward("portlet.ext.listing.view");
}

}

but in receiver, it also return null ...
is there anywhere i miss out ?

Posted by chiochuan on July 13, 2009 at 05:38 AM IST #

Have you tried in normal portlets, not in StrutsPortlet?

Posted by Deepak on July 13, 2009 at 07:37 AM IST #

Hi Deepak,

after run on several testing, i found the the problem cause by
<portlet-url-class>com.liferay.portal.struts.StrutsActionPortletURL</portlet-url-class>
in liferay-portlet-ext.xml
but, when i delete this setting in xml, portlet not working properly ....
could it be StrutsActionPortletURL behavior ?

Thanks

Posted by chiochuan on July 14, 2009 at 08:13 AM IST #

Hi Deepak,
Now iam using the publishing Event and processing It Using the EventStoryBoard with the netbeans Here I dont have any problem with communicating the Two wars in liferay iam able to publish the variables in one war and receiving it another war.It Worked for me very fine .. with the glassfish because i added portal.container.impl=sun in the portal-ext.properties.....in liferayglassfish522

But the Problem is When iam using the Jsp portlets in the Liferay iam unable to pass the variables it always giving the null values.Here my jsp pages includes Html pages so is there any way to communicate between the Jsps which includes the Html pages..Using the Public renderParameter if not is there any other way to communicate these two wars...

Posted by srinivas on July 21, 2009 at 12:10 PM IST #

Deepak, Excellent post.
We are not using liferay but using WebSphere 6.1 which support jsr 286. We do not use local portlets but only remote portlets. I have deployed two separate WAR file on producer and consuming those two portlets on same page.
But not able to pass render parameter between two portlets. I know that by default the render param scope is global so it shld be able to pass.

Any thoughts ?

Mehul

Posted by Mehul Shah on July 24, 2009 at 03:27 PM IST #

If you want to pass render parameters between two portlets you need to use public render parameters. Render Parameters by default are not global, they are private to that portlet.

Posted by Deepak on July 27, 2009 at 07:09 AM IST #

I may have skipped over this somewhere, but is there a way to set a default value to public render parameters? I can get them to pass between portlets properly it's just that when first loading the portlets 'null' is in the fields. A default value of "" would make it appear nicer.

Posted by Daniel Wilberger on July 29, 2009 at 02:51 PM IST #

There is no default value for public render parameters.

Posted by Deepak on July 30, 2009 at 03:41 AM IST #

Is there any way to create one so that 'null' doesn't go into the text fields the first time the page is loaded?

Posted by Daniel Wilberger on July 30, 2009 at 11:04 AM IST #

I would handle this using a utility class something like..
<input type="text" value="<%=ParamUtil.getString(renderRequest.getParameter(..)%>"

ParamUtil.getString will return "", if renderRequest.getParameter returns null.

Posted by Deepak on July 30, 2009 at 12:40 PM IST #

Thank you I never even thought of that.

Posted by Daniel Wilberger on July 30, 2009 at 03:42 PM IST #

Hello,

I would recommend to follow:
http://www.liferay.com/web/steven.cao/blog/-/blogs/jsr-286-new-features-1-in-5-public-render-parameter

I used it and it works fine.

Regards.

Posted by Rajesh Murli on August 14, 2009 at 02:28 PM IST #

Hi There,

I am looking for IPC method, which allows me to exchange data between two portlets, which are NOT on the same page.

I am aware of a cache solution (IBM/dynacache) or the bundling portlets into the same war and use session etc. I am looking for an alternative!

Does anybody have a suggestion?

Posted by robertt on August 24, 2009 at 07:37 PM IST #

"I am aware of a cache solution (IBM/dynacache) or the bundling portlets into the same war and use session etc. I am looking for an alternative! "

How about using URL ? I used it to share some basic variables (usually id, e.g. userId, articleId, etc) using URL.

This depends on portal you use, e.g. Liferay works fine with URL parameters as it does not delete parameters from URL when navigating around portal...

Idea is to use httpSession and queryString together with jsf externalContext to construct URL, add your parameters and rewrite it. If you use struts this is easy, in JSF is possible but relies on few tricks.

Posted by Petar on August 24, 2009 at 08:33 PM IST #

Hi,
I have been getting so many queries on this, I blogged about this. http://blogs.sun.com/deepakg/entry/coordination_between_portlets_across_pages
Thanks for triggering this.

Posted by Deepak on August 25, 2009 at 05:12 AM IST #

Hi Deepak,
Can we deploy two JSR286 portlets on two different containers (on different machines)and still get them communicating with each other using events or IPC?

Posted by Hariom Tiwari on September 23, 2009 at 08:58 AM IST #

This can be done via WSRP(http://wsrp.dev.java.net)

Posted by Deepak on October 01, 2009 at 05:53 AM IST #

Hi Deepak,

Thank you very much for your article and replies to the queries posted by many. Just by going through these posts, I fixed many issues.

Posted by Prashanth on November 17, 2009 at 09:16 AM IST #

It was a very nice idea! Just wanna say thank you for the information you have shared. Just continue writing this kind of post. I will be your loyal reader. Thanks again.

Posted by links of london jewellery on November 25, 2009 at 12:36 AM IST #

This was exactly what I was looking for, in terms of how to use the public render parameters..

Thanks, Deepak..!!

- Josh

Posted by Josh on November 28, 2009 at 06:41 PM IST #

Hello Deepak,
My application require showing and hiding of portlet dynamically.
I was able to achieve this through backing file in synchronous mode.
But the same i wasn't able to do in asynchronous mode.
Application is showing an error as to unable to find instance of invisible portlet.
Can you please some help

Thanks & regards
Kushal

Posted by Kushal Bandi on June 19, 2010 at 04:10 PM IST #

need some more details in order to help, like how did you convert to asynchronous mode mode, the exception stack trace etc..

Posted by Deepak on June 21, 2010 at 03:31 AM IST #

Hello Deepak .. thanks so much for your prompt reply ..

1) I am using Weblogic Portal 10.3.2 and all portlets are java portlets.
2) in the ControllerPortlet's doView i am invoking the presentationContexts of each of the 3 portlets & setting setVisible(false), so that the 3 portlets are not rendered on PageLoad
3) in the ControllerPortlet's jsp i hv checkboxes by which i want to dynamically show any of the 3 portlets one at a time. I have done this by setting backingContext.setVisible for the respective portlet in the processAction of the ControllerPortlet.
4) Also to ensure that the remaining 2 portlets do NOT re-render, i am setting a Public Render Param in the processAction of the ControllerPortlet for each portlet, so that only the selected Portlet (which has subscribed to the public render param) gets triggered

For eg. if I select Portlet1 from the ControllerPortlet for showing dynamically, the ControllerPortlet's processAction sets the Portlet1BackingContext.setVisible(true) & also does actionResponse.setRenderParam("prp_portlet1", "show"). The prp_portlet1 is a public render param to which only the Portlet1 is subscribed (thru the Supported Public render param tag in porlet.xml) and hence Portlet1's doView gets executed (as required). However when the response comes to the browser, the javascript is unable to find the ajax tag for portlet1 (because it was never rendered on page load) & gives the error.
Instead if I do NOT hide the portlets by default (on page load) & then try to dynamically hide/show them it works perfectly fine.
But my requirement is to keep them hidden by default & dynamically show them one by one without impacting the other portlets.

Can you please guide me on how to achieve this?

Thanks again ..

Posted by Kushal Bandi on June 21, 2010 at 07:47 AM IST #

I am using JSF portlets in RAD7.5.3 and running on WPS6.1

I am trying to create Portlet url as follow:
targetPageUrl = PortletURLHelper.generateUrl
( forgotPwdUtils.PWD_REC_PAGE_UNIQUE_NAME, forgotPwdUtils.PWD_REC_LAYOUT_UNIQUE_NAME,
(HashMap<String,String[]>) ParamMap, false,
request, response );
It is creating url for that target page, but this parameter are getting added in JSF session and not in URL. value is null for all keys. It might be exceeding url length so that it is adding there. How can we avoid it? Any configuration?

Posted by dhananjay on September 08, 2010 at 06:29 AM IST #

I guess this is related to WebSphere Portal, I think you should ask this query in WPS forum.

Posted by Deepak on September 08, 2010 at 10:55 AM IST #

AS JSR 286 portlet don't have a navigation Parameter as JSR 168, I defined a " public render parameter " but when I put 2 instances of the same portlet on the same page, both of them share the same public render Parameter !

During the design time, when I put the 2 instances of the same portlet on the same page, I see each one have his own parameters and 2 different page parameter was created for each one but at run time I see that both of them share the same parameter as both of them show the same content.

what I did is, I created a "Public Render Parameter" and inside the portlet backing, I access this parameter using the below code:

public String getParam()
{
PortletRequest req = (PortletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();

return req.getParameter("ParamId"); //ParamId is a public render parameter.
}

and in the view page I get this value using EL: #{portletbacking.param}

but when I put 2 instance of the same portlet on the same page, both of them share the same public render param. in the JSR 168, I was using the Navigation Parameter for this case and it was working fine.

Any help will be highly appreciated.

Posted by Fady on December 22, 2010 at 01:39 AM IST #

The public render parameter uniqueness is derived from the Qname. What you say sounds like a bug..Om which portal are you trying this and which jsf portlet bridge?

Posted by Deepak on December 22, 2010 at 03:41 AM IST #

The samples appear not to be available anymore. Whenever I click through to the source, I get:

java.net> projects > portlet-container > Website
The file /web/projects/portlet-container/files/documents/5463/80976/WeatherMap-src.zip appears to be missing.
To add content to your website, use webdavs.

Is the sample available, and if so, at what url?

Posted by Mike on June 22, 2011 at 07:46 PM IST #

You should be able to get the Samples from
http://portlet-container.java.net/public/Samples.html
Also navigable from http://portlet-container.java.net/ -> Download -> Samples

Posted by Deepak on June 23, 2011 at 02:46 PM IST #

Hi Deepak,

I have 2 portlets into one page, and I want to send a string from one portlet to the other.

I understood that I have to use Public Render Parameters.

I defined the param into both portlet.xml files, set the supported-public-render-param, and set the response.setRenderParam method into the processAction method.

But I'm receiving null value, I think because I don't have any action.

So, this is my question, how can I pass this value between portlets if I don't have any action?

Thanks in advance.

Posted by Fab on August 25, 2011 at 12:15 PM IST #

Render is supposed to be idempotent, it should not change unless triggered by action/event request. Instead of actionURL, you can use renderURL to trigger. If a renderURL targeted to a portlet has a public render parameter, then all portlets interested in that will be updated.

Posted by Deepak on August 25, 2011 at 01:57 PM IST #

Hi, thanks for the answer, but I don't have actionURL/renderURL.

I have into the portal page, 2 portlet. Into the first I have the customerCode and I want to pass it to the second portlet to call others methods that need the costumerCode.

How can I pass this customerCode from portlets? I don't click on button or links. I want the same parameter into both portlets.

Thanks

Posted by Fab on August 25, 2011 at 02:08 PM IST #

Looks like the first portlet gets the customerCode from some call within its render method. So when the second portlet is rendered you want it to have the same customerCode. This is not possible via public render parameter. You have to accomplish this via portlet session. i.e, set the value in the first portlet and get it in the second portlet.

Posted by Deepak on August 26, 2011 at 10:01 AM IST #

Hi Deepak, I'm still having the same problem:

Right now I have the two portlets (JSR 286 extending GenericPortlet, not ADF) into the same webapp and into the same portal page.

The first one is shown into all the portal pages and the second one only when the user click on the subscription.jspx page.

When the second portlet is visible I want to show the customerCode that is into the first portlet, so I want this communication: the first portlet sends the customerCode to the second, the second takes the customerCode when is visible.

What do I have to use: public render param, events, portlet session or something else?

Can you write me some example code?

Thanks in advance.

Posted by guest on September 08, 2011 at 09:08 AM IST #

If the action on the first portlet causes the whole page(that includes the second portlet) to render, then use public render parameter. If that is not the case, then use portlet session.

Posted by Deepak on September 08, 2011 at 09:33 AM IST #

I'm trying the public render parameters but I don't have any action, so I don't know how to initialize the render parameter with a value coming from a web service.

So I want to show the customerCode into the first portlet, taking the customerCode from a web service, initialize the render parameter with this customerCode and then show the customerCode into the second portlet taking the customerCode from the parameters without any click or something else just using the doView methods of both portlets, is it possible?

Existe some kind of order when the application try to render the pages of the portlets?

Thanks

Posted by guest on September 08, 2011 at 01:18 PM IST #

Deepak,
I'm curious as to whether further development is being done on the portlet-container OpenPortal project. I'm interested in contributing source code.

- Derrick

Posted by Derrick on October 04, 2011 at 11:48 AM IST #

Hi Derrick,
The current development in OpenPortal Portlet Container is limited to bug fixes. As and when a user report a issue/contributes a patch, it is being addressed. You are welcome to contribute the source code.

Thanks,
Deepak

Posted by Deepak on October 05, 2011 at 09:20 AM IST #

Hi Deepak,
I am using liferay6.0 with tomact 6.0 versions to develop my portlet application, I am getting following issue when redirecting the request

1) Can we use public render parameters technique to share variables from one portlet to another portlet which is in different portal page in the same war file?

2) When i am redirecting a request from one portlet to another by using actionResponse.sendRedirect("/url"), i am getting java.lang.reflect.InvocationTargetException.

Any techniques to share data between two or more portlets on different pages in the same war file?

Any answers or suggestions are most welcome

Thanks in advance
-Johny

Posted by Johny on December 23, 2011 at 11:43 AM IST #

Hi Johny,
I think the capability to share public render parameters across pages has been added in Liferay 6. If that does not work you can use PortletSession to share data between portlets.

-Deepak

Posted by Deepak on December 24, 2011 at 01:23 PM IST #

Hi Deepak, Thanks for the answer.

But I do not want to use session technique to share the data between portlets that are in different pages.

Any mechanisms for this issue other than session and events?

Thanks,
-Johny

Posted by Johny on December 26, 2011 at 07:04 AM IST #

Hi Johny,
If Liferay does not provide the capability to share the data between portlets that are in different pages, then unfortunately there is no other way except to use Portlet Session.

-Deepak

Posted by Deepak on December 26, 2011 at 11:07 AM IST #

Hi Deepak,

Using Public Render Parameters (IPC), how to communicate between portlets in same page without refreshing whole portal page.

Posted by Ashwini on January 28, 2012 at 03:00 PM IST #

IPC via Public Render Parameters happens only after refresh, if you want to transfer parameter from one portlet to another without, you have to trigger serveResource call to the portlet you want to refresh when action is triggered.

Posted by Deepak on January 30, 2012 at 10:05 PM IST #

Hi.. through public render parameters : How do we communicate between two portlets of different portlet application.

please tell the configuration in portlet.xml of both portlets.

Posted by guest on April 13, 2012 at 06:48 AM IST #

I can't obtain the WeatherMap.war ,it gives me an error link, can you provide a valid link, can't you?

thanks a lot.

Posted by janice on July 05, 2012 at 10:26 PM IST #

You can download the samples from http://portlet-container.java.net/public/Samples.html

Posted by Deepak on July 05, 2012 at 10:29 PM IST #

Hi Deepak,
I am converting from JSR 168 to JSR 286. Is there a way to convert or use wire from wsdl instead of event to communicate between portlets?

Thanks for Help

Aga

Posted by guest on July 19, 2012 at 02:56 AM IST #

As far as i am aware there is no such way.

Posted by Deepak on July 19, 2012 at 05:22 PM IST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Deepak Gothe

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today