Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Cocoon Wiki" for change 
notification.

The following page has been changed by AlexanderKlimetschek:
http://wiki.apache.org/cocoon/JXTemplateGenerator

------------------------------------------------------------------------------
  === JSTL and XPath ===
  
  The JX!TemplateGenerator provides a generic page templating mechanism. You 
can embed either JSTL or XPath expressions to access data from several 
implicitly defined Cocoon objects (e.g. request, session etc.), or from objects 
you have passed to the JX!TemplateGenerator from your flow script. For example, 
this is how you would access the current contination id using each expression 
language:
+  *  Using [http://jakarta.apache.org/commons/jexl JSTL(Apache Jexl)]: {{{ 
${cocoon.continuation.id} }}}
+  *  Using [http://jakarta.apache.org/commons/jxpath XPath(Apache JXPath)]: 
{{{ #{$cocoon/continuation/id} }}}
+  *  Using Javascript: {{{ @{cocoon.get('continuation').getId()} }}}
+ 
+ As one can see, you explicitly need knowledge about the object types and 
their methods when using the Javascript notation. The other to (JSTL and 
JXPath) are much easier, they simplify the access to Maps and getProperty() 
methods by using the "." notation.
+ 
+ Older Cocoon without {{{cocoon.}}} prefix (not sure when there was a 
change...):
-  *  Using [http://jakarta.apache.org/commons/jexl JSTL(Apache Jexl)]: 
${continuation.id}
+  *  Using [http://jakarta.apache.org/commons/jexl JSTL(Apache Jexl)]: {{{ 
${continuation.id} }}}
-  *  Using [http://jakarta.apache.org/commons/jxpath XPath(Apache JXPath)]: 
#{$continuation/id}
+  *  Using [http://jakarta.apache.org/commons/jxpath XPath(Apache JXPath)]: 
{{{ #{$continuation/id} }}}
  
  === Accessing data from implicitly defined Cocoon objects ===
  
  You have access to some implicitly defined objects (available through both 
JSTL and XPath):
+  *  cocoon - Base object, holding all the other ones to avoid conflicts with 
variables from a flowscript
-  *  continuation - The current flow script continuation
+   *  continuation - The current flow script continuation
-  *  request - The Cocoon current request 
({{{org.apache.cocoon.environment.Request}}})
+   *  request - The Cocoon current request 
({{{org.apache.cocoon.environment.Request}}})
-  *  session - The Cocoon session associated with the current request 
({{{org.apache.cocoon.environment.Session}}})
+   *  session - The Cocoon session associated with the current request 
({{{org.apache.cocoon.environment.Session}}})
-  *  context - The Cocoon context associated with the current request 
({{{org.apache.cocoon.environment.Context}}})
+   *  context - The Cocoon context associated with the current request 
({{{org.apache.cocoon.environment.Context}}})
-  *  parameters - A map of parameters passed to the generator in the pipeline 
({{{org.apache.avalon.framework.parameters.Parameters}}})
+   *  parameters - A map of parameters passed to the generator in the pipeline 
({{{org.apache.avalon.framework.parameters.Parameters}}})
+ 
+ An access to the request uri for example would be (JSTL): {{{ 
${cocoon.request.uri} }}}
  
  ==== Accessing sitemap parameters ====
  
@@ -32, +42 @@

  {{{<map:generate src="jxtemplate.xml" type="jx">
    <map:parameter name="my-param" value="my-value"/>
  </map:generate}}}
- To access the value of {{{my-param}}} in your jxtemplate.xml file (using JSTL 
in this case) your expression would look like this: 
${cocoon.parameters['my-param']}
+ To access the value of {{{my-param}}} in your jxtemplate.xml file (using JSTL 
in this case) your expression would look like this: 
${cocoon.parameters['my-param']} (when you have simpler names without special 
characters like "-", you won't need the {{{['something']}}} notation but can 
still use {{{ ${cocoon.parameters.something}}}} ).
  
  === Accessing data passed from your flow scripts ===
  
  You may also pass Java Beans, DOM, JDOM, or !JavaScript objects from your 
flow scripts. Once again, this will work in both JSTL and XPath. For example:
  {{{var greatlakes = ["Superior", "Michigan", "Huron", "Erie", "Ontario"];
  sendPage(uri, {"greatlakes" : greatlakes});}}}
+ 
+ Those parameters can be accessed as top-level variables, eg. accessing 
"greatlakes" is as easy as (JSTL): {{{ ${greatlakes} }}}.
  
  == Basic features ==