It’s common to create portlets that extend javax.portlet.GenericPortlet
. After
all, GenericPortlet
provides a default javax.portlet.Portlet
interface
implementation. Upgrading a GenericPortlet
is straightforward and takes only
two steps:
-
Adapt the portlet to Liferay DXP 7.0’s API using the Upgrade Planner.
-
Resolve its dependencies.
This tutorial demonstrates upgrading a Liferay Plugins SDK 6.2 sample portlet
called Sample DAO (project sample-dao-portlet
).
The sample portlet lets users view, add, edit, and delete food items from a listing. For reference, you can download the pre-upgraded portlet code and the upgraded code.
The sample portlet has the following characteristics:
- Extends
GenericPortlet
- View layer implemented by JSPs
- Persists models using the Data Access Object (DAO) design pattern
- Specifies database connection information in a properties file
- Manages dependencies via Ant/Ivy
- Developed in a Liferay Plugins SDK 6.2
The portlet uses a traditional Plugins SDK portlet project folder structure.
Upgrading most GenericPortlet
portlets involves these steps:
Since the sample portlet’s dependencies haven’t changed, upgrading it involves only adapting the code to Liferay DXP 7.0’s API. The Upgrade Planner facilitates updating the code and resolving compilation issues quickly.
You deploy a GenericPortlet
to Liferay DXP 7.0 in the same way you deploy to
Portal 6.x. When the plugin WAR file lands in the [Liferay_Home]/deploy
folder, Liferay DXP’s Plugin Compatibility Layer converts the WAR to a Web
Application Bundle (WAB) and installs the portlet as a WAB to Liferay DXP’s OSGi
runtime.
On deploying an upgraded portlet, the server prints messages that indicate the following portlet status:
- WAR processing
- WAB startup
- Availability to users
Deploying the sample portlet produces messages like these:
20:57:02,571 INFO ... [com.liferay.portal.kernel.deploy.auto.AutoDeployScanner][AutoDeployDir:252] Processing sample-dao-portlet-7.0.0.1.war
...
20:57:12,639 INFO [fileinstall-C:/portals/liferay-dxp-digital-enterprise-7.0-sp1/osgi/war][BundleStartStopLogger:35] STARTED sample-dao-portlet_7.0.0.1 [996]
...
20:57:13,480 INFO [fileinstall-C:/portals/liferay-dxp-digital-enterprise-7.0-sp1/osgi/war][PortletHotDeployListener:313] 1 portlet for sample-dao-portlet is available for use
The portlet is now available on Liferay DXP.
You’ve learned how to upgrade and deploy a portlet that extends
GenericPortlet
. You adapt the code, resolve dependencies, and deploy the
portlet as you always have. It’s just that easy!
Related Topics
Migrating Plugins SDK Projects to Workspace and Gradle