The portlet filter is similar to the servlet filter. It executes some logic before and after executing the portlet. Portlet filter is mostly used for the below things.

  • Transform content
  • Add or modify request and response attributes
  • Suspend a portlet phase to get user input
  • Audit portlet activity

1. Create a module project.

  1. Go to Liferay workspace project modules new.
  2. Select other Liferay Liferay Module Project and Click on “Next”.
  3. Enter the project name.
  4. Select “Project Template Name” as “mvc-portlet” and click on “Next”.
  1. Enter the package name and click on “Finish”. The necessary file structure will be created as below.

2. Implement a RenderFilter in your portlet class. : It links the portlet class with the filter class.

service.ranking:Integer : Many times we need to create too many filters, that time we can use service.ranking: Integer. It is useful to execute filters on a priority basis.

3. Now, you can deploy your portlet filter.