Step by step creating a Portlet filter


Portlet Filter are filters that can be applied to any life cycle method(s) of a portlet. Below are the filters that were introduced as part of JSR 286 specification.

javax.portlet.filter.RenderFilter (for render method)
javax.portlet.filter.ActionFilter (for processAction method)
javax.portlet.filter.EventFilter (for processEvent method)
javax.portlet.filter.ResourceFilter (for serveResource method)

To create a custom portlet filter, you are required to do couple of things here :

1) Code your own filter class - A custom filter class should implement one or more of the above 4 defined interfaces with a no argument public constructor. It is also mandatory for filter class to override init() and destroy() methods of PortletFilter interface.

2) Entry of filter class in portlet.xml - The seconds step is to configure the above filter class in portlet.xml

    <value>My first filter</value>


The first xml fragment defines a filter by providing a logical name to it. It tells the portlet container about the newly created custom filter class and the lifecycle phases supported by the filter. In addition to this, you can also specify initialization parameters here.

The Second xml fragment specifies the portlet name for which this filter will be applicable. Here you can specify either a single portlet or mapping to a group of portlets using the wildcard character ‘\*’.

No comments:

Post a Comment

Recent Posts

Popular Posts

© 2011-2019 Web Portal Club