Assigning filters to a portlet | HCL Digital Experience
After you have registered a portlet filtered, you can assign it to a portlet. You can assign multiple portlet filters to a portlet.
About this task
To assign multiple portlet filters to a portlet, you define the portlet setting FilterChain and specify a list of filters separated by commas or semicolons as the value.
To add this setting to the relevant portlet during run time, use the Modify Parameters option in the Manage Portlets portlet.
FilterChain = MyTranscodingFilter, MyAdStripper
In this filter chain example, the filters perform the following actions:
MyTranscodingFilter
can transcode HTML to WML.MyAdStripper
removes the advertisement from the output of the portlet.
The request processes the following steps:
MyTranscodingFilter
is called first. This filter checks the requested markup and detects that WML is requested. Since the portlet supports only HTML, the client in the request is wrapped by this filter with a client-wrapper, which mimes an HTML client for the portlet. In addition, the response must be wrapped with a wrapper that intercepts the output of the following portlet or filters, in order to work on their output.MyAdStripper
does not have to modify the request because it only works on the output, but the response must be wrapped to store the output of the portlet.- The portlet generates its HTML output.
MyAdStripper
on the output of the portlet and will remove the advertisement.MyTranscodingFilter
then works on the output of the previous filter and transcodes this output to WML.
You cannot use multiple filters that can transcode from one markup to another in a single filter chain.
You can also declare the filter chain or parts of the filter chain on a global level for all
portlets written against the HCL Portlet API. To achieve this, you can edit or add a
property FilterChain
containing a comma-separated list of
filters in the PortletFilterService.properties
file, just
like in the example given previously (FilterChain =
MyTranscodingFilter, MyAdStripper
). This global filter chain is merged with the
one defined on a per-portlet basis, while the global ones are applied before the local
ones.