Monday Nov 30, 2009

Resetting the JSF Portlet State

Consider a JSF Portlet having a navigation(what is a JSF app without navigation!!), for example a Search JSF Portlet. It has two pages, "Search Criteria Page" and "Search Results Page".  After you enter the criteria on "Search Criteria Page" and click submit, you will get a "Search Results Page". Add this JSF Portlet on a page in Web Space or Liferay. Now visit some other page and comeback to the page on which you added the JSF Portlet, you will see that it is showing "Search Results Page", i.e the state is retained. This is as per spec and is the correct behaviour. What if you want to see "Search Criteria Page" everytime you visit the page. This can be achieved as follows.

1. In your JSF Portlet, add the following init parameter in the portlet.xml

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

2. In Web Space / Liferay, Click on "Manage Pages"

Manage Pages Drop Down

3. Select the page that has JSF Portlet(in this example, i have it on "jsftest" page). In the "Query String" textfield, enter the value com.sun.faces.portlet.CLEAR_STATE=true. Save the page.

Manage Pages

Now whenever you visit the page you will see the "Search Criteria Page". But if you are doing any action on any other portlet on that page, "Search JSF Portlet" will retain the state. It will not reset to "Search Criteria Page". Resetting happens only when you visit the page. This means, suppose, there is another JSR286 portlet or a JSF Portlet on that page and "Search JSF Portlet" shows "Search Results Page". If you are doing any action on the other portlet and after the page is rendered, "Search JSF Portlet" will continue to show "Search Results Page".

Tuesday Aug 25, 2009

Coordination between portlets across pages

There has been lot of queries asking me how to send/receive events with portlets that are not on same page. So I thought let me blog about this.

In order to provide coordination between portlets the Java Portlet Specification, JSR 286 introduces Eventing and Public Render Parameters

Eventing:

   By default portlets can send and receive events with other portlets that are on the same page. This can be changed to enable portlets to send and receive events from other portlets that are on different pages. This can be done by adding the following property in portal-ext.properties in Web Space server and Liferay Portal 5.2.x.

portlet.event.distribution=ALL_PORTLETS


Public Render Parameters:

   By default portlets can share render states with other portlets that are on the same page. This can be changed to enable portlets to share render states with other portlets that are on different pages. This can be done by adding the following property in portal-ext.properties in Web Space server and Liferay Portal 5.2.x.

portlet.public.render.parameter.distribution=ALL_PORTLETS


Preventing infinite loops in Eventing:

    The following property is used to specify the maximum number of events that can be generated from portlets to prevent infinite loops. If a portlet sends an event to other portlets, it is considered as one event generation. If the other portlets send events, that is considered as two event generations and so on. The default value is 3.

portlet.event.max.generation=3

Monday Jun 29, 2009

ICE Faces Portlet in OpenPortal Portlet Container and Web Space

There has been discussion in ICEFaces forum and at http://portlet-container.dev.java.net mailing list regarding deploying ICEFaces Portlet in OpenPortal Portlet Container. The issue is that after deploying the ICEFaces portlet(that uses AJAX push capability), when you access the Portlet, you get an ICEfaces popup window in the browser with the message "user session expired" and a "Reload" button. Thanks to the ICEFaces team, they found the issue and mentioned that it was related to the cookies for JSESSIONID and paths. The problem is that the portlet container is running in its own context(/portletdriver) separate from the ICE Faces portlet's context for Ajax requests. And the solution suggested was to deploy the portletdriver at root context.

I found another solution which works if you don't want to deploy portletdriver to the root context. This also works for the case where you deploy Web Space server to a non-root context.

This involves adding the following to the sun-web.xml

   <session-config>
        <cookie-properties>
            <property name="cookiePath" value="/" />
        </cookie-properties>
    </session-config>

After adding this entry you need to redeploy the portletdriver.war/webspace.war.

If you are using OpenPortal Portlet Container on Tomcat, you need to add emptySessionPath to the server.xml.

 <Connector port="8080" .... 
         emptySessionPath="true" /> 

Monday Mar 23, 2009

Changing log level in Portlet Container

The Portlet Container 2.x that is part of  Sun GlassFish Web Space Server , Liferay and OpenPortal Portlet Container uses JDK logging (JSR 47) for logging messages , exceptions etc. By default the log level in GlassFish is INFO. If you need to disable the portlet container logs or change the log level, how to do it?. Following are the steps..

  1. Login to GlassFish adminconsole(default: localhost:4848)
  2. Click on "Application Server" on the left side.Then click on Logging->Log levels as shown below




  3. Then scroll down and click on "Add Property" and enter the "debug.com.portal.portletcontainer" in Name field and any valid JDK Log level(eg: INFO or WARNING or SEVERE etc..) in Value field as shown below.




  4. Click on "Save". This should take effect immediately, no restart is required.

        
    

Friday Feb 13, 2009

Portlet Container in Sun GlassFish Web Space Server

Sun GlassFish Web Space Server 10.0 has been released. This release uses Portlet Container 2.1

The Portlet Container 2.1 is a fully compliant implementation of the Portlet 2.0 (JSR286) specification. And it also implements many of the optional features like

You get all these features in Sun GlassFish Web Space Server 10.0 which is based on Liferay Portal 5.2.  Apart from that we have added XMLPortletRequest. More about XMLPortletRequest in my next blog.

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