内に含まその他のドキュメントサポート リソース | PDF 文書ファイルをダウンロードする (472 KB)
Chapter 8 Deploying Struts Application as a Portlet in Portal ServerThis chapter describes how to deploy any existing struts application as a JSR168 portlet in Portal Server. Using the steps mentioned in this document, the entire Struts application can be displayed within a channel on the portal server desktop. It contains the following sections: Preparing the Struts ApplicationThis section contains the following: IntroductionThe extended struts framework shipped with Portal Server is an extension of Struts version 1.2.4. This requires that you must download Standard Struts binary, version 1.2.4, from the struts archive page, and the application must be tested as a standalone application, using standard struts.jar file. This is to ensure that you have the proper version of all the supporting JARs required by the struts framework. Install Portal Server 7 for extended struts framework (struts.jar file) and supporting components (strutssupport.jar, portlet.jar) required to deploy Struts application as JSR168 portlet. Modify Struts ApplicationTo deploy any struts application as a portlet, the struts application is required to follow some of the following rules:
Obtain Portlet Objects in Struts ApplicationIt is possible for struts application to get hold of portlet objects like ActionRequest and ActionResponse. This may be required, for example, to implement EDIT functionality. However, if portlet objects are not used properly, the use of portlet objects in struts application may make it portal dependent and result in the struts application unusable as a standalone application. The struts Action class can obtain javax.portlet.ActionRequest and javax.portlet.ActionResponse objects using the following calls: ActionRequest aReq = (ActionRequest) request.getAttribute("javax.portlet.request");
ActionResponse aRes = (ActionResponse) request.getAttribute("javax.portlet.response");
The above two statements return javax.portlet.RenderRequest and javax.portlet.RenderResponse respectively, when called from a JSP page. Session InformationIf any struts application, deployed as a portlet, is invalidating the session using session.invalidate(), the session obtained by the struts-portlet bridge becomes the invalid one. Because of this, the bridge is unable to store rendering related information. In application server, struts application, deployed as a portlet, must not use session.invalidate() as the same session is used by struts portlet bridge. Creating and Modifying XML FilesThis section contains the following: Modify struts-config.xml FileChange the RequestProcessor to org.apache.struts.action.PortletRequestProcessor or org.apache.struts.tiles.PortletTilesRequestProcessor, if the application is using Tiles. For example: <controller contentType="text/html;charset=UTF-8" debug="3" locale="true" processorClass="org.apahce.struts.action.PortletRequestProcessor"> <!-- The "input" parameter on "action" elements is the name of a local or global "forward" rather than a module-relative path --> <set-property property="inputForward" value="true"/> </controller> Create portlet.xml FileEvery portlet WAR must have one portlet.xml file in the WEB-INF directory of the web application. When creating the portlet.xml file, note that:
Here is a sample portlet.xml file for struts-portlet application: <?xml version="1.0" encoding="UTF-8"?> <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/portlet/porlet-app_1_0.xsd" version="1.0"> <portlet> <portlet-name>StrutsPortlet</portlet-name> <portlet-class>org.apache.struts.action.StrutsPortlet</portlet-class> <init-param> <name>initPage</name> <value>/index.jsp</value> </init-param> <init-param> <name>helpPage</name> <value>/tour.htm</value> </init-param> <init-param> <name>editPage</name> <value>/edit.jsp</value> </init-param> <init-param> <name>factoryPage</name> <value>com.sun.portal.struts.wrapper.PSServletObjectsFactory</value> </init-param> <init-param> <name>config</name> <value>/WEB-INF/struts-config.xml,/WEB-INF/struts-config-registration.xml</value> </init-param> <init-param> <name>servletPage</name> <value>*.do</value> </init-param> <expiration-cache>0</expiration-cache> <supports> <mime-type>text/html</mime-type> <portlet-mode>HELP</portlet-mode> <portlet-mode>EDIT</portlet-mode> </supports> <portlet-info> <title>StrutsPortlet</title> </portlet-info> </portlet> </portlet-app> Building and Deploying the Web Application as a Portlet Application
|