Raible's Wiki

Raible Designs
Wiki Home
Recent Changes


  - Korean
  - Chinese
  - Italian
  - Japanese

QuickStart Guide
  - Chinese
  - French
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish
  - Japanese

User Guide
  - Korean
  - Chinese

  - Chinese
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish

  - Korean

Latest Downloads

Other Applications

Struts Resume
Security Example
Struts Menu

Set your name in

Referenced by

JSPWiki v2.2.33


Hide Menu


Difference between current version and current version:

At line 1 added 121 lines.
This page documents the steps necessary to migrate an existing Struts application for use as a [Jetspeed|http://portals.apache.org/jetspeed-2/] portlet. See the [installing Jetspeed|InstallJetspeed] page if you don't have Jetspeed installed.
The application used for testing and figuring out these steps was the Struts version of [Equinox|http://equinox.dev.java.net]. The struts-demo app that's included in Jetspeed-2 was used as a reference. For this tutorial, Equinox 1.2 was used - and [this change|https://equinox.dev.java.net/source/browse/equinox/build.xml?r1=1.10&r2=1.11] was made to build.xml. To begin, I created an equinox-struts project by downloading/extracting Equinox and then cd-ing into its ''extras/struts'' folder and running "ant test". Make sure Tomcat is stopped when you run this command since this command will actually start Tomcat and run some tests in it.
!Table of Contents
* [1] Add the portals-bridges-struts-0.1.jar to your project
* [2] Modify web.xml to use PortletServlet instead of ActionServlet
* [3] Modify struts-config.xml to override the default RequestProcessor
* [4] Create a portlet.xml file in the WEB-INF directory
* [5] Deploy the WAR to Jetspeed
* [6] Create a .psml file so the portlet will show up in Jetspeed
* [7] Known Issues
!!Add the portals-bridges-struts-0.1.jar to your project [#1]
Once you have equinox-struts and jetspeed setup, copy the portals-bridges-struts-0.1.jar from your local Maven repository into the ''web/WEB-INF/lib'' directory.
cp ~/.maven/repository/portals-bridges/jars/portals-bridges-struts-0.1.jar web/WEB-INF/lib
!!Modify web.xml to use PortletServlet instead of ActionServlet [#2]
Change the "action" servlet in __web/WEB-INF/web.xml__ to use the PortletServlet from the bridge JAR.
!!Modify struts-config.xml to override the default RequestProcessor [#3]
In __web/WEB-INF/struts-config.xml__ add a &lt;controller&gt; element just above the &lt;message-resources&gt; element to override the RequestProcessor.
<!-- ========== Controller Configuration ================================ -->
<controller pagePattern="$M$P" inputForward="true"
!!Create a portlet.xml file in the WEB-INF directory [#4]
Copy and paste the following XML into a __portlet.xml__ file in the __web/WEB-INF__ directory.
<?xml version="1.0" encoding="UTF-8"?>
<portlet-app id="equinox-struts" version="1.0">
<portlet id="Equinox-Struts">
<description>This is a simple portlet</description>
<title>User List</title>
<short-title>This is the short title</short-title>
!!Deploy the WAR to Jetspeed [#5]
In __build.properties__, add a "deploy.dir" property so you can deploy to Jetspeed's deployer.
Edit __web/WEB-INF/classes/jdbc.properties__ and change the "jdbc.url" to use an absolute path. This is necessary so you can populate the HSQL database from the equinox-struts directory.
Start Tomcat and run "ant deploywar" to deploy your portlet. If you're watching Tomcat's log files ($CATALINA_HOME/logs/catalina.out) - and you don't see your WAR getting deployed, make sure the ''portlet.xml'' is in your web/WEB-INF directory.
To update the WAR in Jetspeed, just run "ant deploywar" after you've modified files. To undeploy the WAR, delete the equinox-struts.war file from $CATALINA_HOME/webapps/jetspeed/WEB-INF/deploy.
%%note __NOTE:__ These deployment instructions are based on [this wiki page|http://wiki.apache.org/portals/Jetspeed2/DeployingCustomPortlets].%%
!!Create a .psml file so the portlet will show up in Jetspeed [#6]
Create a __equinox-struts.psml__ file in ''$CATALINA_HOME/webapps/jetspeed/WEB-INF/pages'' with the following contents. The fragment id's must be unique among all .psml files, and the name of the portlet is read from the ''portlet.xml'' file.
<?xml version="1.0" encoding="UTF-8"?>
<page id="equinox-struts">
<fragment id="equinox-struts-layout" type="layout" name="jetspeed::VelocityTwoColumns">
<fragment id="equinox-struts-portlet" type="portlet" name="equinox-struts::Equinox-Struts">
<property layout="TwoColumns" name="row" value="0"/>
<property layout="TwoColumns" name="column" value="0"/>
Open [http://localhost:8080/jetspeed]. You should see a "Equinox-Struts" tab on the opening screen. To populate the values in the HSQL database, run "ant populate" and you should see a list of users when you click on the tab.
!!Known Issues [#7]
* The equinox-struts app is a Struts application that is not modified at all to be used as a portlet. Because of this, most of the app's functionality does not work. [This document|http://cvs.apache.org/viewcvs.cgi/jakarta-jetspeed-2/portals-bridges/struts/README.txt?view=markup] details what you need to do to modify your Struts apps so they can be used as portlets.
* Once you've modified web.xml to use the PortletServlet, it breaks the Action tests that use [MockStrutsTestCase|http://strutstestcase.sourceforge.net/api/servletunit/struts/MockStrutsTestCase.html]. This remains an open issue that we're trying to solve.

Back to StrutsPortlet, or to the Page History.