Upgrading Portlets
Step 6 of 6
Struts is a stable, widely adopted framework that implements the Model View Controller (MVC) design pattern. If you have a Struts portlet for previous versions of Liferay Portal, you can upgrade it to the new DXP version.
Upgrading Struts portlets to the new DXP version is easier than you might think. Liferay DXP lets you continue working with Struts portlets as Java EE web applications.
This tutorial demonstrates how to upgrade a portlet that uses the Struts 1 Framework.
Here’s a sample Struts portlet’s folder structure with file/folder descriptions:
sample-struts-portlet
docroot/
html/portlet/sample_struts_portlet/
→ JSPsWEB-INF/
lib/
→ Required third-party libraries unavailable in the Liferay DXP systemsrc/
com/liferay/samplestruts/model/
→ Model classescom/liferay/samplestruts/servlet/
→ Test servlet and servlet context listenercom/liferay/samplestruts/struts/
action/
→ Action
classes that return View pages to the clientform/
→ ActionForm
classes for model interactionrender/
→ Action
classes that present additional pages and handle inputSampleException.java
→ Exception classcontent/test/
→ Resource bundlesMETA-INF/
→ Javadoctld/
→ Tag library definitionsliferay-display.xml
→ Sets the application categoryliferay-plugin-package.properties
→ Sets metadata and portal dependenciesliferay-portlet.xml
→ Maps descriptive role names to rolesliferay-releng.properties
→ (internal) Release propertiesportlet.xml
→ Defines the portlet and its initialization parameters and security rolesstruts-config.xml
→ Struts configurationtiles-defs.xml
→ Struts Tile definitionsvalidation.xml
→ Defines form inputs for validationvalidation-rules.xml
→ Struts validation rulesweb.xml
→ Web application descriptorbuild.xml
→ Apache Ant build fileUpgrading a Struts 1 portlet involves these steps:
Adapt the portlet to the new DXP version’s API using the Liferay Upgrade Planner. When running the planner’s Fix Upgrade Problems step, many of the existing issues are autocorrected. For remaining issues, the planner identifies code affected by the new API and ways to adapt it.
You’ve resolved the Sample Struts portlet’s dependencies. It’s ready to deploy.
On deploying a Struts portlet Web Application aRchive (WAR), Liferay DXP’s Web Application Bundle (WAB) Generator creates an OSGi module (bundle) for the portlet and installs it to Liferay’s OSGi framework. The server prints messages indicating the following portlet status:
The Struts portlet is now available on your Liferay DXP instance. The Struts portlet behaves just as it did on previous versions on your the new DXP version site.
Congratulations on upgrading your Struts portlet to the new DXP version!