In this post, we will learn the main configuration files and the basic architecture of the Liferay portlet. Please check how to create the Liferay portlet using Liferay Developer Studio, before continuing.

Liferay Portlet contains mainly 4 components: docroot, WEB-INF, WEB_INF/src and build.xml.


docroot: the root directory of the application, contains configuration and other application related files.

WEB-INF: This is the standard WEB_INF folder of a web module. It contains configuration related files.

WEB_INF/src: contains the source code of the portlet.

Build: Ant build script used to compile and deploy.

By default, newly created portlet is configured as standard  java portlet specifications, that uses three separate JSPs for different modes(view, edit and help). By default only view.jsp is implemented.

Liferay related configuration files:

Liferay-display.xml: Contains the categorization of the portlet. This tells under which category portlet will appear.

Liferay-portlet.xml:  Describes optional liferay-specific enhancement for the portlet. Ex: Defining portlet is instantiable or not. It describes the plugin to Liferay’s hot deployer. Dependency jars also can be mentioned using this file.

Portlet.xml: This file contains the portlet related configurations.

  • <portlet-name>: Tells the portlet name, which is used internally to identify the portlet.
  • <display-name>: Tells the Portlet’s display name.
  • <portlet-class>: Tells which class to be invoked for action call.
  • <init-param>: Used to define portlet’s initial parameters. It contains and tags.Ex: view-template which is set to html/view.jsp. This tells that portlet’s default view page is view.jsp
  • <supports>: This tag is used to specify portlets modes like view/edit, etc. By default, Liferay assumes view mode.

Note: Version details: Liferay version 6.2.

You may also interested in