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

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.

Monday Dec 01, 2008

Setting Markup Head Elements in Portlets

JSR 286 (Portlet 2.0 specification) allows the portlet to set HTML elements like <link>, <script>, <meta> in the <head> section of the portal page. This can be achieved via the addProperty method on the RenderResponse with MimeResponse.MARKUP_HEAD_ELEMENT as property name and org.w3c.dom.Element as value.

Following is the code snippet..
import javax.portlet.GenericPortlet;  
import javax.portlet.RenderRequest;  
import javax.portlet.RenderResponse;  
import javax.portlet.MimeResponse;  
import org.w3c.dom.Element;  
public class TestPortlet extends GenericPortlet {  
    @Override
    protected void doHeaders(RenderRequest request, RenderResponse response) {
        Element metaDescription = response.createElement("meta");
        metaDescription.setAttribute("name", "description");
        metaDescription.setAttribute(
              "content", "everything you want to know about stamps");
        response.addProperty(
              MimeResponse.MARKUP_HEAD_ELEMENT, metaDescription);
        Element metaKeywords = response.createElement("meta");
        metaKeywords.setAttribute("name", "keywords");
        metaKeywords.setAttribute("content", "stamps, history");
        response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, metaKeywords);
    }
....
}

This feature has been implemented in OpenPortal Portlet Container 2.0 Update 1.

There has been lot of confusion regarding the role of container runtime option (javax.portlet.renderHeaders) while setting the headers. I get the following question a lot:

Is the container runtime option (javax.portlet.renderHeaders) needed if the portlet wants to set headers?

The answer: It depends on whether the portal is a streaming portal or a buffering portal.
First the definition: In case of streaming portal, the output of the portlet is not buffered, while it is buffered in case of buffering portal.
The buffering portal can ignore the container runtime option whereas it is mandatory in case of streaming portal.

In case of OpenPortal Portlet Container, Project WebSynergy which are buffering portals, the container runtime option(javax.portlet.renderHeaders) is not required to be present in the portlet.xml of the portlet that wants to set the headers.

Tuesday Jul 22, 2008

Article in TheServerSide.com uses OpenPortal Portlet Container

Recently one of colleagues came across an article the TheServerSide.com that explains the "Action Scoped Request attributes" container runtime option. The article uses OpenPortal Portlet Container to explain the feature.

My colleague in his blog talks about this and also why he likes OpenPortal Portlet Container.

Thursday Jul 03, 2008

JSR286: Wildcards in Eventing

The eventing feature in JSR 286 supports wildcard. In order to use wildcard, the portlet must organize the local part of the event names in the event-definition element in a hierarchical manner using the dot(‘.’) as separator. for example: "foo.event.one". 

Wildcards should only be used in the supported-processing-event or supported-publishing-event elements.

If the wildcard string should match a part of a hierarchy two dots are required at the end of the wildcard string: one to denote the hierarchy and one for the wildcard, for example: "foo..".

The event name must be part of the hierarchy, not a substring. For example "foo." matches "foo.bar", but it does not match "football"


Consider the following example:

<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-name>Portlet1</portlet-name>
      ...
      <supported-publishing-event>
         <qname xmlns:x=”http:example.com/events”>x:foo.event.</qname>
      </supported-publishing-event>
      ...
   </portlet>
   <portlet>
      ...
      <portlet-name>Portlet2</portlet-name>
      ...
      <supported-processing-event>
         <qname xmlns:x=”http:example.com/events”>x:foo.event.</qname>
      </supported-processing-event>
      ...
   </portlet>
   <portlet>
      ...
      <portlet-name>Portlet3</portlet-name>
      ...
      <supported-processing-event>
         <qname xmlns:x=”http:example.com/events”>x:foo..</qname>
      </supported-processing-event>
      ...
   </portlet>
   <portlet>
      ...
      <portlet-name>Portlet4</portlet-name>
      ...
      <supported-processing-event>
         <qname xmlns:x=”http:example.com/events”>x:foo.e.</qname>
      </supported-processing-event>
      ...
   </portlet>

   <event-definition>
      <qname xmlns:x=”http:example.com/events”>x:foo.event.one</qname>
      <value-type>com.example.Address</value-type>
   </event-definition>
   <event-definition>
      <qname xmlns:x=”http:example.com/events”>x:foo.event.two</qname>
      <value-type>com.example.Address</value-type>
   </event-definition>
   <event-definition>
      <qname xmlns:x=”http:example.com/events”>x:foo.bar.event</qname>
      <value-type>com.example.Address</value-type>
   </event-definition>
</portlet-app>

  • Portlet1 can publish the events x:foo.event.one and x:foo.event.two as the event definitions "x:foo.event.one" and "x:foo.event.two" begins with "x:foo.event."
  • Portlet2 can process the events x:foo.event.one and x:foo.event.two as the event definitions "x:foo.event.one" and "x:foo.event.two" begins with "x:foo.event."
  • Portlet3 can process the events x:foo.event.one, x:foo.event.two and x:foo.bar.event as the event definitions "x:foo.event.one", "x:foo.event.two" and "x:foo.bar.event" begins with the hierarchy "x:foo."
  • Portlet4 cannot process any event as there is no event that begins with the hierarchy x:foo.e. (Note: e. and event. are two different hierarchies, i.e, e. does not mean starting with e)

The recently released OpenPortal Portlet Container 2.0 supports wildcard in eventing.

Thursday Mar 13, 2008

OpenPortal Portlet Container 2.0 RC1 released

The first Release Candidate of OpenPortal Portlet Container 2.0 (implementation of JSR 286 specification) is now available for download.

Samples are available to test the new features.

It is recommended that you uninstall Portlet Container 2.0 Beta2 before installing RC1

This release has few additional features/enhancements and fixes since the beta2..

  • Support for Container Events
    • Currently login/logout event is supported, more will be added later. Check Issue 66 for the sample
  • Support for Roles
  • JAXB for marshalling/unmarshalling event payload
  • Fix that enables running Visual Web Components as portlets
  • Few enhancements to support WSRP 2.0

The Issue List contains the details of the additional features/enhancements and fixes.

Netbeans Portlet Pack 2.0 Beta3 is available that helps developers to develop, deploy and test portlets on the Portlet Container 2.0 RC1.

If you have questions on how to use the OpenPortal Portlet Container and other comments/suggestions/requests, we urge you to join the users@portlet-container.dev.java.net alias.

Please report any issues that you encounter while trying OpenPortal Portlet Container RC1 to issues@portlet-container.dev.java.net.

Friday Mar 07, 2008

JSR286 : The Eventing feature (updated)

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

To create portlets that use the eventing feature, follow these steps(snippets from EventingMap sample application):

1.Declare the events in the portlet.xml

    1.1 Set the event definition at the portlet application level. This specifies the event name and the object type.
        Note: The object must be serializable and must be instrumented with valid JAXB annotation

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

<event-definition>
<qname xmlns:x="http:sun.com/mapevents">x:Continent</qname>
<value-type>com.sun.portal.portlet.mapevent.Continent</value-type>
</event-definition>

</portlet-app>


@XmlRootElement
public class Continent implements Serializable {
public Continent() {
}
private String name;
private String description;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getDescription() {
return description;
}

public void setDescription(String description)
this.description = description;
}
}

  1.2 In the portlet section, specify the event name defined above for those portlets that want to publish this event.

        <portlet>
<description>ContinentPortlet</description>
<portlet-name>ContinentPortlet</portlet-name>
            .................
<supported-publishing-event>
<qname xmlns:x="http:sun.com/events">x:Continent</qname>
</supported-publishing-event>

        </portlet>


    1.3 In the portlet section, specify the event name defined above for those portlets that want to process this event.

    <portlet> 
<description>ContinentMapPortlet</description>
<portlet-name>ContinentMapPortlet</portlet-name>
. . .
<supported-processing-event>
<qname xmlns:x="http:sun.com/events">x:Continent</qname>
</supported-processing-event>

</portlet>
  <portlet>
<description>ContinentInfoPortlet</description>
<portlet-name>ContinentInfoPortlet</portlet-name>
. . .
<supported-processing-event>
<qname xmlns:x="http:sun.com/events">x:Continent</qname>
</supported-processing-event>

</portlet>
. . .
</portlet-app>

    
2. Issue an event in the portlet that was specified as supported-publishing-event in the portlet.

public class ContinentPortlet extends GenericPortlet {

public void processAction(ActionRequest request, ActionResponse response)
throws PortletException,IOException {

QName qname = new QName("http:sun.com/mapevents" , "Continent")
String value = request.getParameter("continent");
Continent continent = new Continent();
continent.setName(value);

ResourceBundle rb = getPortletConfig().getResourceBundle(request.getLocale());
continent.setDescription(rb.getString(value));
response.setEvent(qname, continent);
}
. . .
}

3. Process the event in the portlet that has specified as supported-processing-event in the portlet

public class ContinentInfoPortlet extends GenericPortlet {

public void processEvent(EventRequest request, EventResponse response) {

Event event = request.getEvent();
if(event.getName().equals("Continent")){
Continent payload = (Continent)event.getValue();
response.setRenderParameter("continentDescription",
payload.getDescription());
}

}

. . .

}


public class ContinentMapPortlet extends GenericPortlet {
public void processEvent(EventRequest request, EventResponse response) {

Event event = request.getEvent();
if(event.getName().equals("Continent")){
Continent payload = (Continent)event.getValue();
response.setRenderParameter("continentName", payload.getName());
}

}
. . .
}

You can download the binary file EventingMap.war 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.

The figure shows the World Map, Continent Information, and Continent Map Portlets that participate in the event. Clicking on any continent in the World Map triggers an event. This event is processed by the Continent Information and Continent Map Portlets to show the relevant information.


Monday Feb 11, 2008

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 

Tuesday Jan 08, 2008

Portlet Container 2.0 Beta2 released

The OpenPortal Portlet Container 2.0 Beta2 has been released. This release is based on JSR 286 proposed final draft. This release contains following features and enhancements..

  • Eventing
  • Public Render Parameters
  • Resource Serving
  • Portlet Filters
  • Validation based caching
  • Request Dispatcher Include from all lifecycle
  • Request Dispatcher Forward from all lifecycle
  • Container Runtime Options that includes escapeXml and actionScopedRequestAttributes
  • Taglibrary enhancements

Netbeans Portlet Pack 2.0 Beta2 is available that helps developers to develop, deploy and test portlets on the Portlet Container 2.0 Beta2.

Thursday Aug 16, 2007

JSR 286 : Public Render Parameters feature

I had written this blog when the early draft of JSR 286 was released. Recently the proposed final draft was released, it has some changes in public render parameter feature. I have written a new blog to explain this feature with an example. 

In order to provide coordination between portlets the Java Portlet Specification, JSR 286 introduces the following mechanisms

  • Eventing: portlet events that a portlet can receive and send
  • Public Render Parameters: render state that can be shared between portlets

In my previous blog, i explained Eventing feature and in this blog will explain the Public Render Parameter feature.

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.

How it works..
Consider the following example..

Declare the render parameters to be shared in the portlet.xml
    1. Set the public render parameters at the portlet application level.
    <portlet-app .....>
        <public-render-parameter>
            <identifier>id1</identifier>
            <qname xmlns:x="http://sun.com/params">x:param1</qname>
        </public-render-parameter>
        <public-render-parameter>
            <identifier>id2</identifier>
            <qname xmlns:x="http://sun.com/params">x:param2</qname>
        </public-render-parameter>

    2. Specify the render parameter the portlet would like to share in the portlet section.
    <portlet>
        ...............
            <portlet-name>PortletA</portlet-name>
        ...............
             <supported-public-render-parameter>id1</supported-public-render-parameter>
             <supported-public-render-parameter>id2</supported-public-render-parameter>
        ...............
    <portlet>
    <portlet>
        ...............
            <portlet-name>PortletB</portlet-name>
        ...............
             <supported-public-render-parameter>id1</supported-public-render-parameter>
        ...............
    <portlet>
    <portlet>
        ...............
            <portlet-name>PortletC</portlet-name>
        ...............
             <supported-public-render-parameter>id2</supported-public-render-parameter>
        ...............
    <portlet>


   
1. If portletA sets the render parameter param1, portletB receives it but not portletC
2. If portletA sets the render parameter param2, portletC receives it but not portletB
3. If portletB sets the render parameter param1, portletA receives it but not portletC
4. If portletC sets the render parameter param2, portletA receives it but not portletB

You can checkout the sources from OpenPortal Portlet Container that has the implementation of the public render parameter feature. Write portlets that uses this feature and try it.

Thursday Aug 09, 2007

JSR 286 : The Eventing feature

In order to provide coordination between portlets the Java Portlet Specification, JSR 286 introduces the  following mechanisms

  • Eventing: portlet events that a portlet can receive and send
  • Public Render Parameters: render state that can be shared between portlets

In this blog, i will explain the Eventing feature and in a later blog i will explain the Public Render Parameter feature.

Eventing can be described as a loosely coupled, brokered means of communication between portlets. It is intended to allow portlets to react on actions or state changes not directly related to an interaction of the user with the portlet.
Events are a lifecycle operation that occurs before the rendering phase.


Now let us get into the details of writing portlets that use this feature

The portlet can declare the events in its deployment descriptor using the event-definition element in the portlet application section. In the portlet section each portlet can specify the events it would like to publish via the supported-publishing-event element and the events it would like to process via the supported-processing-event element. The supported-publishing-event and supported-processing-event element must reference the event name defined in the portlet application section in a event-definition element.

The portlet issues events via the setEvent method during the action processing. This will be processed by the portlet container after the action processing has finished.

In order to receive events the portlet must implement the javax.portlet.EventPortlet interface. The portlet container will call the processEvent method for each event targeted to the portlet with an EventRequest and EventResponse object.
The portlet can access the event that triggered the current process event call by using the EventRequest.getEvent method. This method returns an object of type Event encapsulating the current event name and value.

Event names are represented as QNames in order to make them uniquely identifiable. The event name can be either retrieved with the getQName method that returns the complete QName of the event, or with the getName method that only returns the local part of the event name. The value of the event must be based on the type defined in the deployment descriptor.

Following are the steps to write portlets that make use of eventing feature

1.Declare the events in the portlet.xml
    1.1 Set the event definition at the portlet application level. This specifies the event name and the object type.
          Note: The object must be serializable.
    <portlet-app .....>
        <event-definition>
        <qname xmlns:x="http:sun.com/events">
            x:Address.Create
        </qname>
        <value-type>com.test.Address</value-type>
        </event-definition>

    1.2 In the portlet section, specify the event name defined above for those portlets that want to publish this event.
        <portlet>
            .................
            <supported-publishing-event xmlns:x="http:sun.com/events">
                    x:Address.Create
            </supported-publishing-event>

    1.3 In the portlet section, specify the event name defined above for those portlets that want to process this event.
        <portlet>
            .................
           <supported-processing-event xmlns:x="http:sun.com/events">
                  x:Address.Create
           </supported-processing-event>

    
2.Issue an event in the portlet that was specified as supported-publishing-event in the portlet
    @XmlRootElement
    public class Address implements Serializable
    {
        private String street;
        private String city;
        public void setStreet(String s) {street = s;}
        public String getStreet() { return street;}
        public void setCity(String c) { city = c;}
        public String getCity() { return city;}
    }

    void processAction(ActionRequest request, ActionResponse response)
    {
        String myStreet = request.getParameter("street");
        String myCity = request.getParameter("city");
        Address sampleAddress = new Address();
        sampleAddress.setStreet(myStreet);
        sampleAddress.setCity(myCity);
        QName name = new QName("http:sun.com/events", "Address.Create");
        response.setEvent(name, sampleAddress);
    }     

3.Process the event in the portlet that has specified as supported-processing-event in the portlet
    void processEvent(EventRequest request, EventResponse response)
    {
        Event event = request.getEvent();
        if ( event.getName().equals("Address.Create") )
        {
            Address payload = (Address) event.getValue();
            .......
        }
    }

You can checkout the sources from OpenPortal Portlet Container that has the implementation of the eventing feature. Write a portlet that uses the eventing feature and try it.

 

Tuesday Jul 03, 2007

New Contributor to JSF Portlet Bridge Project

The JSF Portlet Bridge Project is making steady progress. Late last year the project released JSF Portlet Bridge 1.2 which enables running JSF 1.2 applications as portlets in the OpenPortal Portlet Container. The project team is currently improving on that implementation.

   I would also like to welcome a new member to the project -- A. Alonso Dominguez, from Social Labs NetSolutions.  He is actively contributing for the implementation of JSR 301 in the project. JSR 301 is the Portlet Bridge Specification for JavaServer Faces Technology. It standardizes the behaviour of bridge implementations to ensure true interoperability for JSF artifacts. See the JSF Portlet Bridge Project for more details.

Friday Mar 23, 2007

Open Source Portlet Container Article

Following on the heels of part 1 and part 2 of the Portal Open Source series of articles, here is part 3

Open-Source Portal Initiative at Sun, Part 3: Portlet Container

This article describes the Enterprise-Class Portlet Container Open Source Project and Portlet Container 1.0, recently developed for that project. Also explained are the procedures for installing and deploying Portlet Container 1.0 so as to test portlets.
 

Thursday Mar 22, 2007

Portal Server Logging - Part 2

In Part 1, i wrote about the basic logging features of Sun Java System Portal Server 7.x. In this part i will explain few advanced  features(rest i will cover in part 3), these include

As mentioned in part 1, if the portlet deployment fails, you need to check the logs from PAS(Portal Administration Server). By default the log level is SEVERE. For debugging purposes you need to decrease the log level. This can be done by using the CLI command

<portal-install-dir>/bin/psadmin set-logger -u amadmin -f <password-file> -m pas -O debug.com.sun.portal -L FINEST

This works very well, but if you feel that too much log is generated and if you are interested only in the portlet deployment related logs, then you need to change the log level of the portlet related logger as follows.

Changing the log level of a logger 

1. First you need to know the name of the portlet related logger, issue the following command to get the list of loggers

<portal-install-dir>/bin/psadmin list-loggers -u amadmin -f <password-file> -m pas

The output will be something like this

debug.com.sun.portal
debug.com.sun.portal.admin.server
debug.com.sun.portal.audit
debug.com.sun.portal.community.admin.mbeans
debug.com.sun.portal.desktop.admin.mbeans
debug.com.sun.portal.desktop.dp.xml
debug.com.sun.portal.fabric.mbeans
debug.com.sun.portal.fabric.tasks
debug.com.sun.portal.fabric.util
debug.com.sun.portal.monitoring.admin.mbeans
debug.com.sun.portal.portlet.admin.mbeans
debug.com.sun.portal.portlet.admin.mbeans.tasks
debug.com.sun.portal.portletcontainercommon.descriptor
debug.com.sun.portal.rewriter.admin.mbeans
debug.com.sun.portal.sra.admin.mbeans
debug.com.sun.portal.ssoadapter.mbeans
debug.com.sun.portal.subscriptions.admin.mbeans
debug.com.sun.portal.ubt.admin.mbeans
debug.com.sun.portal.wsrp.consumer.admin.mbeans
debug.com.sun.portal.wsrp.producer.admin.mbeans
 

In the above list portlet related loggers are "debug.com.sun.portal.portlet.admin.mbeans" and "debug.com.sun.portal.portlet.admin.mbeans.tasks". You need to use "debug.com.sun.portal.portlet.admin.mbeans", because "debug.com.sun.portal.portlet.admin.mbeans" is parent logger of "debug.com.sun.portal.portlet.admin.mbeans.tasks".

2. Now set the log level for the portlet logger as follows

<portal-install-dir>/bin/psadmin set-logger -u amadmin -f <password-file> -m pas -O debug.com.sun.portal.portlet.admin.mbeans -L FINEST

After issuing this command, you will see that only portlet related logs is appearing in the log level FINEST, while the rest is still at the level SEVERE

Redirecting the logs from a logger to different file

Is there a way to isolate the logs related to portlet so i don't need to search for portlet related logs in the portal.0.0.log file. This can be done as follows

<portal-install-dir>/bin/psadmin set-logger -u amadmin -f <password-file> -m pas -O debug.com.sun.portal.portlet.admin.mbeans -L FINEST --file

This creates a separate file for all the logs from portlet logger(i.e all the logs that has the logger "debug.com.sun.portal.portlet.admin.mbeans.\*" will be in new file and the name of the file will be portal.portlet.admin.mbeans.0.0.log)

After the problem is found, you may want to reset the logger back to the parent log file. this can be done as follows 

<portal-install-dir>/bin/psadmin reset-logger -u amadmin -f <password-file> -m pas -O debug.com.sun.portal.portlet.admin.mbeans

After this command, the logs from portlet logger will go to the parent log file, i.e portal.0.0.log, with the same level as that of the parent.

 

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