Using filters

Filter definition and mapping in portlet.xml

<filter>
<filter-name>Example ColdFusion Filter</filter-name>
<filter-class>coldfusion.portlet.ColdFusionPortletFilter</filter-class>
<lifecycle>RENDER_PHASE</lifecycle>
<lifecycle>EVENT_PHASE</lifecycle>
<lifecycle>RESOURCE_PHASE</lifecycle>
<lifecycle>ACTION_PHASE</lifecycle>
<init-param>
<name>cfcName</name>
<value>portlets.filter.ExampleFilter</value>
</init-param>
</filter>
<filter> <filter-name>Example ColdFusion Filter</filter-name> <filter-class>coldfusion.portlet.ColdFusionPortletFilter</filter-class> <lifecycle>RENDER_PHASE</lifecycle> <lifecycle>EVENT_PHASE</lifecycle> <lifecycle>RESOURCE_PHASE</lifecycle> <lifecycle>ACTION_PHASE</lifecycle> <init-param> <name>cfcName</name> <value>portlets.filter.ExampleFilter</value> </init-param> </filter>
<filter> 
<filter-name>Example ColdFusion Filter</filter-name> 
<filter-class>coldfusion.portlet.ColdFusionPortletFilter</filter-class> 
<lifecycle>RENDER_PHASE</lifecycle> 
<lifecycle>EVENT_PHASE</lifecycle> 
<lifecycle>RESOURCE_PHASE</lifecycle> 
<lifecycle>ACTION_PHASE</lifecycle> 
<init-param> 
<name>cfcName</name> 
<value>portlets.filter.ExampleFilter</value> 
</init-param> 
</filter>

Add filter mapping, that filter applied to particular portlet.

<!-- Applies Example Filter to All Portlets -->
<filter-mapping>
<filter-name>Example ColdFusion Filter</filter-name>
<portlet-name>*</portlet-name>
</filter-mapping>
<!-- Applies Example Filter to All Portlets --> <filter-mapping> <filter-name>Example ColdFusion Filter</filter-name> <portlet-name>*</portlet-name> </filter-mapping>
<!-- Applies Example Filter to All Portlets --> 
<filter-mapping> 
<filter-name>Example ColdFusion Filter</filter-name> 
<portlet-name>*</portlet-name> 
</filter-mapping>

ExampleFilter.cfc:

The following is the ExampleFilter.cfc mentioned in the portlet.xml.

<cfcomponent extends="CFIDE.portlets.filter.ColdFusionPortletFilter">
<cffunction name="doRenderFilter" returntype="void">
<cfargument name="renderRequest">
<cfargument name="renderResponse">
<cfargument name="filterChain">
<cflog file="portlet-filter" type="information" text="doRenderFilter() invoked">
<!--- call the next filter in the chain --->
<cfset arguments.filterChain.doFilter(arguments.renderRequest, arguments.renderResponse)>
</cffunction>
<cffunction name="doActionFilter" returntype="void">
<cfargument name="actionRequest">
<cfargument name="actionResponse">
<cfargument name="filterChain">
<cflog file="portlet-filter" type="information" text="doActionFilter() invoked">
<!--- call the next filter in the chain --->
<cfset arguments.filterChain.doFilter(arguments.actionRequest, arguments.actionResponse)>
</cffunction>
<cffunction name="doResourceFilter" returntype="void">
<cfargument name="resourceRequest">
<cfargument name="resourceResponse">
<cfargument name="filterChain">
<cflog file="portlet-filter" type="information" text="doResourceFilter() invoked">
<!--- call the next filter in the chain --->
<cfset arguments.filterChain.doFilter(arguments.resourceRequest, arguments.resourceResponse)>
</cffunction>
<cffunction name="doEventFilter" returntype="void">
<cfargument name="eventRequest">
<cfargument name="eventResponse">
<cfargument name="filterChain">
<cflog file="portlet-filter" type="information" text="doEventFilter() invoked">
<!--- call the next filter in the chain --->
<cfset arguments.filterChain.doFilter(arguments.eventRequest, arguments.eventResponse)>
</cffunction>
</cfcomponent>
<cfcomponent extends="CFIDE.portlets.filter.ColdFusionPortletFilter"> <cffunction name="doRenderFilter" returntype="void"> <cfargument name="renderRequest"> <cfargument name="renderResponse"> <cfargument name="filterChain"> <cflog file="portlet-filter" type="information" text="doRenderFilter() invoked"> <!--- call the next filter in the chain ---> <cfset arguments.filterChain.doFilter(arguments.renderRequest, arguments.renderResponse)> </cffunction> <cffunction name="doActionFilter" returntype="void"> <cfargument name="actionRequest"> <cfargument name="actionResponse"> <cfargument name="filterChain"> <cflog file="portlet-filter" type="information" text="doActionFilter() invoked"> <!--- call the next filter in the chain ---> <cfset arguments.filterChain.doFilter(arguments.actionRequest, arguments.actionResponse)> </cffunction> <cffunction name="doResourceFilter" returntype="void"> <cfargument name="resourceRequest"> <cfargument name="resourceResponse"> <cfargument name="filterChain"> <cflog file="portlet-filter" type="information" text="doResourceFilter() invoked"> <!--- call the next filter in the chain ---> <cfset arguments.filterChain.doFilter(arguments.resourceRequest, arguments.resourceResponse)> </cffunction> <cffunction name="doEventFilter" returntype="void"> <cfargument name="eventRequest"> <cfargument name="eventResponse"> <cfargument name="filterChain"> <cflog file="portlet-filter" type="information" text="doEventFilter() invoked"> <!--- call the next filter in the chain ---> <cfset arguments.filterChain.doFilter(arguments.eventRequest, arguments.eventResponse)> </cffunction> </cfcomponent>
<cfcomponent extends="CFIDE.portlets.filter.ColdFusionPortletFilter"> 
<cffunction name="doRenderFilter" returntype="void"> 
<cfargument name="renderRequest"> 
<cfargument name="renderResponse"> 
<cfargument name="filterChain"> 
<cflog file="portlet-filter" type="information" text="doRenderFilter() invoked"> 
<!--- call the next filter in the chain ---> 
<cfset arguments.filterChain.doFilter(arguments.renderRequest, arguments.renderResponse)> 
</cffunction> 
<cffunction name="doActionFilter" returntype="void"> 
<cfargument name="actionRequest"> 
<cfargument name="actionResponse"> 
<cfargument name="filterChain"> 
<cflog file="portlet-filter" type="information" text="doActionFilter() invoked"> 
<!--- call the next filter in the chain ---> 
<cfset arguments.filterChain.doFilter(arguments.actionRequest, arguments.actionResponse)> 
</cffunction> 
<cffunction name="doResourceFilter" returntype="void"> 
<cfargument name="resourceRequest"> 
<cfargument name="resourceResponse"> 
<cfargument name="filterChain"> 
<cflog file="portlet-filter" type="information" text="doResourceFilter() invoked"> 
<!--- call the next filter in the chain ---> 
<cfset arguments.filterChain.doFilter(arguments.resourceRequest, arguments.resourceResponse)> 
</cffunction> 
<cffunction name="doEventFilter" returntype="void"> 
<cfargument name="eventRequest"> 
<cfargument name="eventResponse"> 
<cfargument name="filterChain"> 
<cflog file="portlet-filter" type="information" text="doEventFilter() invoked">
<!--- call the next filter in the chain ---> 
<cfset arguments.filterChain.doFilter(arguments.eventRequest, arguments.eventResponse)> 
</cffunction> 
</cfcomponent>

Get help faster and easier

New user?