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: Expression Languages
Date Thu, 07 Jun 2007 18:04:33 GMT
A new document has been created.

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

Document ID: 1390
Branch: main
Language: default
Name: Expression Languages
Document Type: Cocoon Document
Created: 6/7/07 6:04:16 PM
Creator (owner): Reinhard Pötz
State: publish

Parts
=====

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

<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>

</body>
</html>

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

Mime
View raw message