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 Liferay DXP 7.1.
Upgrading Struts portlets to Liferay DXP 7.1 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 class
content/test/
→ Resource bundlesMETA-INF/
→ Javadoc
tld/
→ 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 descriptor
build.xml
→ Apache Ant build file
Upgrading a Struts 1 portlet involves these steps:
-
Adapt the portlet to Liferay DXP 7.1’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:
- WAR processing
- WAB startup
- Availability to users
The Struts portlet is now available on your Liferay DXP instance. The Struts portlet behaves just as it did on previous versions on your Liferay DXP 7.1 site.
Congratulations on upgrading your Struts portlet to Liferay DXP 7.1!