cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@cocoon.zones.apache.org
Subject [DAISY] Updated: Advanced Control Flow - JXTemplate
Date Thu, 07 Jun 2007 18:07:54 GMT
A document has been updated:

http://cocoon.zones.apache.org/daisy/legacydocs/511.html

Document ID: 511
Branch: main
Language: default
Name: Advanced Control Flow - JXTemplate (previously Tags)
Document Type: Cocoon Document (unchanged)
Updated on: 6/7/07 6:07:36 PM
Updated by: Reinhard Pötz

A new version has been created, state: publish

Parts
=====

Content
-------
This part has been updated.
Mime type: text/xml (unchanged)
File name:  (unchanged)
Size: 22766 bytes (previous version: 16646 bytes)
Content diff:
    <html>
    <body>
    
+++ <h1>JXTemplate Generator</h1>
+++ 
+++ <p>The JXTemplate Generator is a page template processor that allows you to
+++ inject data from Java and JavaScript objects passed by a Cocoon Flowscript into
+++ a Cocoon pipeline. It provides a set of tags (similar to the
+++ <a href="http://java.sun.com/products/jsp/jstl/">JSTL</a> core tags) that
allow
+++ you to iterate over Java collections (and Java or JavaScript arrays) and to test
+++ for the presence of optional or alternate bean properties, as well as embedded
+++ expressions to specify conditions and to access the properties of objects. The
+++ <em>JX</em>Template Generator gets its name from the embedded expression
+++ languages it supports, namely
+++ <a href="http://jakarta.apache.org/commons/jxpath">Apache <em>JX</em>Path</a>
+++ and <a href="http://jakarta.apache.org/commons/jexl">Apache
+++ <em>J</em>e<em>X</em>l</a>.</p>
+++ 
+++ <p>To use the JXTemplate Generator, add a generator entry to your
+++ <a href="daisy:580">sitemap</a> with the <tt>src</tt> attribute
set to
+++ <tt>org.apache.cocoon.generation.JXTemplateGenerator</tt>, for example like
+++ this:</p>
+++ 
+++ <pre>&lt;map:generators&gt;
+++   &lt;map:generator label="content,data" 
+++       logger="sitemap.generator.jx" name="jx" 
+++          src="org.apache.cocoon.generation.JXTemplateGenerator"/&gt;
+++ &lt;/map:generators&gt;
+++ </pre>
+++ 
+++ <h1>Expression Languages</h1>
+++ 
+++ <p>The JXTemplate Generator supports two embedded expression languages:
+++ <a href="http://jakarta.apache.org/commons/jexl">Jexl</a> and
+++ <a href="http://jakarta.apache.org/commons/jxpath">JXPath</a>. Apache
+++ <a href="http://jakarta.apache.org/commons/jexl">Jexl</a> provides an extended
+++ version of the expression language of the
+++ <a href="http://java.sun.com/webservices/docs/1.0/tutorial/doc/JSTL.html">JSTL</a>.
+++ Apache <a href="http://jakarta.apache.org/commons/jxpath">JXPath</a> provides
an
+++ interpreter of the <a href="http://www.w3.org/TR/xpath">XPath</a> expression
+++ language that can apply XPath expressions to graphs of Java objects of all
+++ kinds: JavaBeans, Maps, Servlet contexts, DOM etc, including mixtures thereof.
+++ </p>
+++ 
+++ <p>Having an embedded expression language allows a page author to access an
+++ object using a simple syntax such as</p>
+++ 
+++ <pre>&lt;site signOn="${accountForm.signOn}"&gt;
+++ </pre>
+++ 
+++ <p>Embedded Jexl expressions are contained in <tt>${}</tt>.</p>
+++ 
+++ <p>Embedded JXPath expressions are contained in <tt>#{}</tt>.</p>
+++ 
+++ <p>The referenced objects may be Java Beans, DOM, or JavaScript objects from a
+++ Flowscript. In addition, a special <tt>cocoon</tt> object providing access
to
+++ the Cocoon <a href="daisy:518#FOM">FOM</a> is available as both a JXPath and
+++ Jexl variable in a template.</p>
+++ 
+++ <p>The <tt>cocoon</tt> object contains the following properties:</p>
+++ 
+++ <ul>
+++ <li><a href="daisy:518#request">request</a>: <br/>
+++ The current Cocoon request</li>
+++ <li><a href="daisy:518#session">session</a>: <br/>
+++ The user session associated with the current request</li>
+++ <li><a href="daisy:518#context">context</a>: <br/>
+++ The Cocoon context associated with the current request</li>
+++ <li><tt>parameters</tt>: <br/>
+++ A map containing the parameters passed to the generator in the pipeline</li>
+++ <li><a href="daisy:518#WebContinuation">continuation</a>: <br/>
+++ The current Web Continuation from your Flowscript</li>
+++ </ul>
+++ 
+++ <p>Jexl Example:</p>
+++ 
+++ <pre>The content type of the current request is ${cocoon.request.contentType}
+++ </pre>
+++ 
+++ <p>JXPath Example:</p>
+++ 
+++ <pre>The content type of the current request is #{$cocoon/request/contentType}
+++ </pre>
+++ 
+++ <p>You would typically access the <tt>id</tt> of the Web Continuation:</p>
+++ 
+++ <pre>&lt;form action="${cocoon.continuation.id}"&gt;
+++ </pre>
+++ 
+++ <p>You can also reach previous continuations via its <tt>parent</tt>
property:
+++ </p>
+++ 
+++ <pre>&lt;form action="${cocoon.continuation.parent.id}" &gt;
+++ </pre>
+++ 
+++ <p>or using an XPath expression:</p>
+++ 
+++ <pre>&lt;form action="#{$cocoon/continuation/parent/id}" &gt;
+++ </pre>
+++ 
+++ <p>Deprecated Variables:</p>
+++ 
+++ <p>The following variables are deprecated but still supported:</p>
+++ 
+++ <ul>
+++ <li>
+++ <a href="file:/home/daisy/tmpdocimport/documentation/apidocs/org/apache/cocoon/environment/Request.html">org.apache.cocoon.environment.Request</a>
+++ <tt>request</tt>: <br/>
+++ The current Cocoon request (deprecated: use <tt>cocoon.request</tt> instead)
+++ </li>
+++ <li>
+++ <a href="file:/home/daisy/tmpdocimport/documentation/apidocs/org/apache/cocoon/environment/Session.html">org.apache.cocoon.environment.Session</a>
+++ <tt>session</tt>: <br/>
+++ The current user session (deprecated: use <tt>cocoon.session</tt> instead)</li>
+++ <li>
+++ <a href="file:/home/daisy/tmpdocimport/documentation/apidocs/org/apache/cocoon/environment/Context.html">org.apache.cocoon.environment.Context</a>
+++ <tt>context</tt>: <br/>
+++ The current context (deprecated: use <tt>cocoon.context</tt> instead)</li>
+++ <li>
+++ <a href="file:/home/daisy/tmpdocimport/documentation/apidocs/org/apache/cocoon/components/flow/WebContinuation.html">org.apache.cocoon.components.flow.WebContinuation</a>
+++ <tt>continuation</tt>: <br/>
+++ The current Web Continuation (deprecated: use <tt>cocoon.continuation</tt>
+++ instead)</li>
+++ </ul>
+++ 
+++ <p class="note">When used inside flow, JXTemplate has access to Java and can
+++ therefore evaluate expressions like "java.util.Date()" or "java.util.HashMap()".
+++ This does <strong>NOT</strong> work when JXTemplates are used without flow.
Some
+++ symptoms:<br/>
+++ [*&lt;jx:out value="${java.util.Date()"/&gt;*] results in [**]</p>
+++ 
+++ <p class="note">&lt;jx:formatDate value="${java.util.Date()}"
+++ pattern="yyyyMMdd"/&gt; results in 'Cannot format given Object as a Date'</p>
+++ 
+++ <h1>Parameters</h1>
+++ 
+++ <h2>lenient-xpath</h2>
+++ 
+++ <p>By default XPath evaluation throws an exception if the supplied XPath does
+++ not map to an existing property. This constraint can be relaxed by setting the
+++ parameter <tt>lenient-xpath</tt> to <tt>true</tt>. In the lenient
mode
+++ evaluation simply returns null if the path maps to nothing.</p>
+++ 
+++ <p>Example:</p>
+++ 
+++ <pre>    &lt;map:match pattern="*.jx"&gt;
+++       &lt;map:generate type="jx" src="documents/{1}.jx"&gt;
+++            &lt;map:parameter name="lenient-xpath" value="true"/&gt;
+++       &lt;/map:generate&gt;
+++       &lt;map:serialize type="xhtml"/&gt;
+++     &lt;/map:match&gt;
+++ </pre>
+++ 
+++ <h1>Tags</h1>
+++ 
    <p>The JXTemplate Generator tags are defined in the namespace</p>
    
    <pre>http://apache.org/cocoon/templates/jx/1.0
(565 equal lines skipped)


Collections
===========
Removed from collection: cdocs-template
Added to collection: legacydocs

Mime
View raw message