cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [DAISY] Created: Expression Languages
Date Thu, 07 Jun 2007 18:04:33 GMT
A new document has been created.

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


Mime type: text/xml
Size: 4195 bytes

<p>The JXTemplate Generator supports two embedded expression languages:
<a href="">Jexl</a> and
<a href="">JXPath</a>. Apache
<a href="">Jexl</a> provides an extended
version of the expression language of the
<a href="">JSTL</a>.
Apache <a href="">JXPath</a> provides
interpreter of the <a href="">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>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;

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

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

<p>Jexl Example:</p>

<pre>The content type of the current request is ${cocoon.request.contentType}

<p>JXPath Example:</p>

<pre>The content type of the current request is #{$cocoon/request/contentType}

<p>You would typically access the <tt>id</tt> of the Web Continuation:</p>

<pre>&lt;form action="${}"&gt;

<p>You can also reach previous continuations via its <tt>parent</tt> property:

<pre>&lt;form action="${}" &gt;

<p>or using an XPath expression:</p>

<pre>&lt;form action="#{$cocoon/continuation/parent/id}" &gt;

<p>Deprecated Variables:</p>

<p>The following variables are deprecated but still supported:</p>

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

<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
[*&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>


The document belongs to the following collections: cdocs-template

View raw message