cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@cocoon.apache.org
Subject [Cocoon Wiki] Updated: JXTemplateGenerator
Date Fri, 10 Dec 2004 15:48:04 GMT
   Date: 2004-12-10T07:48:04
   Editor: MarkLeicester <mark.leicester@efurbishment.com>
   Wiki: Cocoon Wiki
   Page: JXTemplateGenerator
   URL: http://wiki.apache.org/cocoon/JXTemplateGenerator

   Added information about accessing sitemap parameters

Change Log:

------------------------------------------------------------------------------
@@ -7,21 +7,36 @@
 Sitemap Configuration:
 {{{<map:generator name="jx" src="org.apache.cocoon.generation.JXTemplateGenerator" label="content"
logger="sitemap.generator.jx"/>}}}
 
-Provides a generic page template with embedded JSTL and XPath expression substitution to
access data sent by Cocoon Flowscripts, eg. web continuation.[[BR]]
- *  Accessing through [http://jakarta.apache.org/commons/jexl JSTL(Apache Jexl)]: ${continuation.id}
- *  Accessing through [http://jakarta.apache.org/commons/jxpath XPath(Apache JXPath)]: #{$continuation/id}
+== Accessing data with the JXTemplateGenerator ==
 
-There are some objects implicitly available through both expression languages:
+=== 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)]: ${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):
+ *  continuation - The current flow script continuation
  *  request - The Cocoon current request ({{{org.apache.cocoon.environment.Request}}})
  *  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}}})

  *  parameters - A map of parameters passed to the generator in the pipeline ({{{org.apache.avalon.framework.parameters.Parameters}}})
 
-When using JX!TemplateGenerator you probably want to pass data from your flow. You may pass
Java Beans, DOM, JDOM, or !JavaScript objects as these are recognized by both, XPath and JSTL.
Pass these objects as 'Bizdata', for example in Flowscript:
-{{{
-var greatlakes = ["Superior", "Michigan", "Huron", "Erie", "Ontario"];
+==== Accessing sitemap parameters ====
+
+Cocoon sitemap parameters are accessed through the {{{parameters}}} object. For example,
your sitemap might look like this:
+{{{<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']}
+
+=== Accessing data passed from your flow scripts ===
 
-sendPage(uri, {greatlakes: greatlakes}); }}}
+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});}}}
 
 == Basic features ==
 

Mime
View raw message