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 Portal CE 7.0’s API using the Code Upgrade Tool.
Resolve its dependencies.
This tutorial demonstrates upgrading a Liferay Plugins SDK 6.2 sample portlet called Sample DAO (project
The sample portlet has the following characteristics:
- 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.
GenericPortlet portlets involves these steps:
Since the sample portlet’s dependencies haven’t changed, upgrading it involves only adapting the code to Liferay Portal CE 7.0’s API. The Code Upgrade Tool facilitates updating the code and resolving compilation issues quickly.
You deploy a
GenericPortlet to Liferay Portal CE 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 Portal’s Plugin Compatibility Layer converts the WAR to a Web Application Bundle (WAB) and installs the portlet as a WAB to Liferay Portal’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-220.127.116.11.war ... 20:57:12,639 INFO [fileinstall-C:/portals/liferay-dxp-digital-enterprise-7.0-sp1/osgi/war][BundleStartStopLogger:35] STARTED sample-dao-portlet_18.104.22.168  ... 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 Portal.
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!