This wiki does not contain official documentation and is currently deprecated and read only. Please try reading the documentation on the Liferay Developer Network, the new site dedicated to Liferay documentation. DISCOVER Build your web site, collaborate with your colleagues, manage your content, and more. DEVELOP Build applications that run inside Liferay, extend the features provided out of the box with Liferay's APIs. DISTRIBUTE Let the world know about your app by publishing it in Liferay's marketplace. PARTICIPATE Become a part of Liferay's community, meet other Liferay users, and get involved in the open source project. About Portlets
Alternative Languages: 日本語
Table of Contents [-]
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."
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:
- Are the preferences of the portlet unique for each individual page (a.k.a. layout) that contains it?
- 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" />
</definition>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:
Replace:
boolean portletPadding = GetterUtil.getBoolean(tilesPortletPadding, true);
if (!portletDecorate) {
portletPadding = false;
}With:
boolean portletPadding = GetterUtil.getBoolean(tilesPortletPadding, true);
boolean isWAR = ((PortletConfigImpl)portletConfig).isWARFile();
if (!portletDecorate || isWAR) {
portletPadding = false;
}