« Torna a Portlets

About Portlets

Alternative Languages: 日本語

This page is about portlets in general. For Liferay Portlets, see Portlets.

What is a Portlet #

From WikiPedia - Portlet:

"Portlets are pluggable user interfacesoftware components that are managed and displayed in a web portal. Portlets produce fragments of markup code that are aggregated into a portal page. Typically, following the desktop metaphor, a portal page is displayed as a collection of non-overlapping portlet windows, where each portlet window displays a portlet. Hence a portlet (or collection of portlets) resembles a web-based application that is hosted in a portal. Some examples of portlet applications are email, weather reports, discussion forums, and news.

Portlet standards are intended to enable software developers to create portlets that can be plugged in to any portal supporting the standards.

The Java Portlet Specification (JSR168, JSR286) enables interoperability for portlets between different web portals. This specification defines a set of APIs for interaction between the portlet container and the portlet addressing the areas of personalization, presentation and security."

-WikiPedia - Portlet

Portlet configuration #

The portlets available to the portal are defined in WEB-INF/portlet.xml (the JSR168 portlet descriptor file), and WEB-INF/liferay-portlet.xml (the liferay specific portlet descriptor file). Liferay specific configuration includes options such as:

  1. Are the preferences of the portlet unique for each individual page (a.k.a. layout) that contains it?
  2. Are the preferences owned by the group (a.k.a. community) that the user is in (i.e. is there a single configuration for the entire group?)

Portlet source code #

The primary presentation code for the core portlets in the system can be found in /portal/portal-web/docroot/html/portlet/<nameOfPortlet>'. Generally speaking, the view.jsp file is the first hunk of content displayed by a portlet.

Most of the time, the .jsp code contains Javascript that causes a form to be submitted to the portal server whenever an action occurs. These actions set a hidden form variable named "CMD", which contains the "command" to be executed, then submits the form to the server. The server ends up calling a custom Struts action handler to carry out the functionality. The action handler in turns call a service method on one of the services.

The action handler code is generally found in /portal/portal-ejb/com/liferay/portlet/<nameOfPortlet>/action. The action then calls the various ServiceUtil.java service facades that make the call to the middle tier.

Misc info #

This is accurate as of Liferay 4.2.1 Unless configured otherwise, a padding of style="padding: 4px 8px 10px 8px;" is placed around all portlets. This can be suppressed by setting the tiles attribute portlet_padding to false by modifying the /ext/ext-web/docroot/WEB-INF/tiles-defs.xml file. An example of an entry:

 <definition name="portlet.iframe" extends="portlet">
     <put name="portlet_padding" value="false" />

Note: the above fix only applies to portlets deployed inside liferay's classloader. For externally-deployed wars, the following change must also be made to html/common/themes/portlet.jsp:


  boolean portletPadding = GetterUtil.getBoolean(tilesPortletPadding, true);
  if (!portletDecorate) {
     portletPadding = false;


  boolean portletPadding = GetterUtil.getBoolean(tilesPortletPadding, true);
  boolean isWAR = ((PortletConfigImpl)portletConfig).isWARFile();
  if (!portletDecorate || isWAR) {
     portletPadding = false;

Related Articles #

JSR168 Portlets Roster

0 Allegati
49322 Visualizzazioni
Media (0 Voti)
La media del punteggio è 0.0 stelle su 5.