cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@cocoon.zones.apache.org
Subject [DAISY] Created: AJAX migration guide
Date Tue, 10 Apr 2007 12:59:51 GMT
A new document has been created.

http://cocoon.zones.apache.org/daisy/documentation/1350.html

Document ID: 1350
Branch: main
Language: default
Name: AJAX migration guide
Document Type: Cocoon Document
Created: 4/10/07 12:59:40 PM
Creator (owner): Grzegorz Kossakowski
State: publish

Parts
=====

Content
-------
Mime type: text/xml
Size: 2574 bytes
Content:
<html>
<body>

<h1>Introduction</h1>

<p>Ajax block has been recently adapted to use features that servlet services
framework provides. For in-depth details of adoption process take a look at
<a href="http://issues.apache.org/jira/browse/COCOON-1991">COCOON-1991</a>
issue.</p>

<p>Here you'll find description of migration process which should be easy and
straightforward. It is assumed that you already have proper block structure
created with archetype, see <a href="daisy:1159">Your first Cocoon application
using Maven 2</a>.</p>

<h2>Connecting servlets</h2>

<p>First of all, in order to get access to the resources that Ajax block makes
available you need to create a connection to its servlet. Open
src/main/resources/META-INF/cocoon/spring/servlet-service.xml for edition and
put this configuration inside <tt>&lt;servlet:context&gt;</tt> tag:</p>

<pre>&lt;servlet:connections&gt;
  &lt;entry key="ajax" value-ref="org.apache.cocoon.ajax.impl.servlet"/&gt;
&lt;/servlet:connections&gt;
</pre>

<h2>Links adjustments</h2>

<p>Now you can reference resources with special <tt>servlet:</tt> scheme.
For
example, if you have following link to dojo.js:</p>

<pre>&lt;script type="text/javascript" src="${cocoon.request.contextPath}/_cocoon/resources/dojo/dojo.js"/&gt;
</pre>

<p>You will have to change it into following form:</p>

<pre>&lt;script type="text/javascript" src="servlet:ajax:/resources/dojo/dojo.js"/&gt;
</pre>

<p>Basically, replacing <tt>${cocoon.request.contextPath}/_cocoon/</tt>
and
similar construct with <tt>servlet:ajax:/</tt> should do the trick.</p>

<h2>Sitemap adjustments</h2>

<p>Naturally, browsers do not understand <tt>servlet:</tt> scheme and all
links
containing it should be rewritten before sent any content is sent to the
browser. For this purpose, special <tt>servletLinkRewriter</tt> has been
created. You have to put it in your pipeline near html serializer to be sure
that it catches all links that need rewriting. Let's take as example pipeline
from cocoon-ajax-sample:</p>

<pre>&lt;map:match pattern="*.html"&gt;
   &lt;map:generate type="jx" src="{1}.xml"/&gt;
   &lt;map:call resource="simple-page2html"/&gt;
<strong>   &lt;map:transform type="servletLinkRewriter"/&gt;</strong>
   &lt;map:serialize type="html"/&gt;
&lt;/map:match&gt;
</pre>

<p>Transforming step that you need to add was put in bold. Revisiting all your
rendering pipelines and adding transformer is last step.</p>

<p>At the end, rebuild your block, clear browser's cache and test the changes.
All should work as before migration.</p>

</body>
</html>

Collections
===========
The document belongs to the following collections: cdocs-ajax

Mime
View raw message