Expression Languages
The JXTemplate Generator supports two embedded expression languages: Jexl and JXPath. Apache Jexl provides an extended version of the expression language of the JSTL. Apache JXPath provides an interpreter of the XPath expression language that can apply XPath expressions to graphs of Java objects of all kinds: JavaBeans, Maps, Servlet contexts, DOM etc, including mixtures thereof.
Having an embedded expression language allows a page author to access an object using a simple syntax such as
<site signOn="${accountForm.signOn}">
Embedded Jexl expressions are contained in ${}.
Embedded JXPath expressions are contained in #{}.
The referenced objects may be Java Beans, DOM, or JavaScript objects from a Flowscript. In addition, a special cocoon object providing access to the Cocoon FOM is available as both a JXPath and Jexl variable in a template.
The cocoon object contains the following properties:
- request
The current Cocoon request - session
The user session associated with the current request - context
The Cocoon context associated with the current request - parameters:
A map containing the parameters passed to the generator in the pipeline - continuation
The current Web Continuation from your Flowscript - settings
The Cocoon settings object holds the global configuration of Cocoon.
The content type of the current request is ${cocoon.request.contentType}JXPath Example:
The content type of the current request is #{$cocoon/request/contentType}You would typically access the id of the Web Continuation:
<form action="${cocoon.continuation.id}">You can also reach previous continuations via its parent property:
<form action="${cocoon.continuation.parent.id}" >or using an XPath expression:
<form action="#{$cocoon/continuation/parent/id}" >Deprecated Variables:
The following variables are deprecated but still supported:
-
org.apache.cocoon.environment.Request
request:
The current Cocoon request (deprecated: use cocoon.request instead) -
org.apache.cocoon.environment.Session
session:
The current user session (deprecated: use cocoon.session instead) -
org.apache.cocoon.environment.Context
context:
The current context (deprecated: use cocoon.context instead) -
org.apache.cocoon.components.flow.WebContinuation
continuation:
The current Web Continuation (deprecated: use cocoon.continuation instead)
[*<jx:out value="${java.util.Date()"/>*] results in [**]