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><servlet:context></tt> tag:</p> <pre><servlet:connections> <entry key="ajax" value-ref="org.apache.cocoon.ajax.impl.servlet"/> </servlet:connections> </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><script type="text/javascript" src="${cocoon.request.contextPath}/_cocoon/resources/dojo/dojo.js"/> </pre> <p>You will have to change it into following form:</p> <pre><script type="text/javascript" src="servlet:ajax:/resources/dojo/dojo.js"/> </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><map:match pattern="*.html"> <map:generate type="jx" src="{1}.xml"/> <map:call resource="simple-page2html"/> <strong> <map:transform type="servletLinkRewriter"/></strong> <map:serialize type="html"/> </map:match> </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