Content
This document describes how to run a existing cocoon application as a JSR168 portlet. The following example illustrates how to deploy a subapplication as a JSR168 portlet in Pluto. It should work with any JSR 168 portlet Container.
Tested on
- jdk 1.4.2_04-b05
- cocoon 2.1.6
- pluto-src-1.0.1-rc2
- Tomcat 4.1.31
Deployment
- copied blocks.properties to
local.blocks.properties
and disabled the scratchpad and cron (this one caused a problem on my configuration, but you might leave that step out) blocks - created a
portlet.xml
in<COCOON_HOME>/src/webapp/WEB-INF
by using<COCOON_HOME>/src/blocks/portal/WEB-INF/portlet.xml
as a base and removed the first portlet node so that you only keep the secondportlet
node (portlet-name
=CocoonPortlet
). You're might be interested in changing theinit-param
servlet-path
e.g. to the value/yourCocoonSubapp
to see the output you normally get when opening http://localhost:8080/cocoon/yourCocoonSubapp if you have a subapp in that directory. - modify
<COCOON_HOME>/src/webapp/WEB-INF/cocoon.xconf
to include the following input moduleNo Format <component-instance class="org.apache.cocoon.components.modules.input.PortletURLModule" logger="core.modules.mapper" name="portlet"/>
Wiki Markup it will be used by the [LinkRewriterTransformer] described \[#linkproblem below\]. \\
- built cocoon war (
build war
) from source - deleted content of
<TOMCAT_HOME>/common/endorsed
- copied
<COCOON_HOME>/lib/endorsed/x*.jar
to<TOMCAT_HOME>/common/endorsed
- built pluto-src-1.0.1-rc2 (
maven fullDeployment
) - ran
maven deploy -Ddeploy=<COCOON_HOME>/build/cocoon-2.1.6/cocoon.war
- add
<load-on-startup>1</load-on-startup>
to the servlets withservlet-name
Cocoon
andXindice
in<TOMCAT_HOME>/webapps/cocoon/WEB-INF/web.xml
- deleted
<TOMCAT_HOME>/webapps/cocoon/WEB-INF/lib/pluto-1.0.1-rc1.jar
(makes trouble) - you can savely delete
portlet-api-1.0.jar
(optional) - modified
<TOMCAT_HOME>/webapps/pluto/WEB-INF/data/portletcontexts.txt
No Format /testsuite /cocoon
- modified
<TOMCAT_HOME>/webapps/pluto/WEB-INF/data/portletentityregistry.xml
to include the following inside the<portlet-entity-registry>
node:No Format <application id="9"> <definition-id>cocoon</definition-id> <portlet id="1"> <definition-id>cocoon.CocoonPortlet</definition-id> </portlet> </application>
- modified
<TOMCAT_HOME>/webapps/pluto/WEB-INF/data/pageregistry.xml
to include the following inside of the<portal>
node:No Format <fragment name="cocoon" type="page"> <navigation> <title>Cocoon </title> <description>Cocoon distribution...</description> </navigation> <fragment name="row6" type="row"> <fragment name="col6" type="column"> <fragment name="p7" type="portlet"> <property name="portlet" value="9.1"/> </fragment> </fragment> </fragment> </fragment>
Your cocoon app should now be available as a portlet under http://localhost:8080/pluto/portal/cocoon
Anchor | ||||
---|---|---|---|---|
|
<a href="link.html">link</a>
you have to write <a href="portlet:render:link.html">link</a>
. You can add the Transformer to your sitemap like this: No Format |
---|
<map:components> <map:transformer name="linkrewriter" src="org.apache.cocoon.transformation.LinkRewriterTransformer"> <link-attrs>href src</link-attrs> <schemes>portlet</schemes> <input-module name="portlet"/> </map:transformer> </map:transformers> </map:components> |
Then modify your pipeline as follows to actually use the linkrewriter:
No Format |
---|
<map:match pattern=""> <map:read src="cocoon:/index.html"/> </map:match> <map:match pattern="*.html"> <map:generate src="content/{1}.xml"/> <map:transform type="linkrewriter"/> <map:transform src="style/xsl/page2html.xsl"/> <map:serialize type="html"/> </map:match> |
I've not tried to use CForms but I think VadimGritsenko has a solution for this in a blog entry.