cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Cocoon Wiki] Update of "JXTemplateGenerator" by LeszekGawron
Date Mon, 05 Sep 2005 10:29:32 GMT
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 LeszekGawron:
http://wiki.apache.org/cocoon/JXTemplateGenerator

The comment on the change is:
Added docs for <jx:out value="${var}" xmlize="true" strip-root="true"/>

------------------------------------------------------------------------------
  [http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/generation/JXTemplateGenerator.html
JXTemplateGenerator JavaDoc]
  
- Keep in mind that there's also a JX!TemplateTransformer with the same functionality. 
+ Keep in mind that there's also a JX!TemplateTransformer with the same functionality.
  
  Current namespace: {{{xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"}}}
  
@@ -22, +22 @@

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

+  *  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}}})
  
  ==== Accessing sitemap parameters ====
@@ -53, +53 @@

         body
      </jx:otherwise>
  </jx:choose>}}}
-  
+ 
  === jx:forEach ===
  Iterate over a collection of objects.
  {{{
@@ -69, +69 @@

  === jx:formatDate ===
  The formatDate tag provides facilities to format Date values.
  {{{
- <jx:formatDate value="Expression" 
+ <jx:formatDate value="Expression"
-                [dateStyle="Style"] 
+                [dateStyle="Style"]
-                [timeStyle="Style"] 
+                [timeStyle="Style"]
-                [pattern="Expression"] 
+                [pattern="Expression"]
-                [type="Type"] 
+                [type="Type"]
                 [var="Name"]
                 [locale="Expression"]> }}}
  
  === jx:formatNumber ===
- The formatNumber tag is used to display numeric data, including currencies and percentages,
in a locale-specific manner. The formatNumber> action determines from the locale, for example,
whether to use a period or a comma for delimiting the integer and decimal portions of a number.

+ The formatNumber tag is used to display numeric data, including currencies and percentages,
in a locale-specific manner. The formatNumber> action determines from the locale, for example,
whether to use a period or a comma for delimiting the integer and decimal portions of a number.
  {{{
- <jx:formatNumber value="Expression" 
+ <jx:formatNumber value="Expression"
-                  [type="Type"] 
+                  [type="Type"]
-                  [pattern="Expression"] 
+                  [pattern="Expression"]
-                  [currencyCode="Expression"] 
+                  [currencyCode="Expression"]
-                  [currencySymbol="Expression"] 
+                  [currencySymbol="Expression"]
-                  [maxIntegerDigits="Expression"] 
+                  [maxIntegerDigits="Expression"]
-                  [minIntegerDigits="Expression"] 
+                  [minIntegerDigits="Expression"]
-                  [maxFractionDigits="Expression"] 
+                  [maxFractionDigits="Expression"]
-                  [minFractionDigits="Expression"] 
+                  [minFractionDigits="Expression"]
-                  [groupingUsed="Expression"] 
+                  [groupingUsed="Expression"]
-                  [var="Name"] 
+                  [var="Name"]
                   [locale="Expression"]> }}}
  
  === jx:if  ===
@@ -158, +158 @@

  Evaluates an expression and outputs the result of the evaluation:
  {{{
  <jx:out value="Expression"/>}}}
+ Please note that jx:out automatically handles objects of type Node, Node[], NodeList, XMLizable
and renders them as SAX events.
+ 
+ Cocoon 2.2: You can make JXTG parse expression string result into SAX events by using following
syntax:
+ {{{
+ <jx:out value="Expression" xmlize="true"/>}}}
+ Additionally you can ignore root element of generated content with {{{strip-root="true"}}}
attribute.
+ 
+ Example:
+ 
+ {{{
+ myXml = "<root><p>content</p><p>content2</p></root>";
+ 
+ <nonxmlized><jx:out value="${myXml}"/></nonxmlized>
+ <xmlized><jx:out value="${myXml}" xmlize="true" strip-root="true"/></xmlized>
+ 
+ result is:
+ <nonxmlized>&lt;root&gt;&lt;p&gt;content&lt;/p&gt;&lt;p&gt;content2&lt;/p&gt;&lt;/root&gt;</nonxmlized>
+ <xmlized><p>content</p><p>content2</p></xmlized>}}}
  
  === jx:set ===
  Define/set a variable
@@ -177, +195 @@

  }}}
  
  === jx:attribute (cocoon 2.2-dev) ===
- Set's an attribute. 
+ Set's an attribute.
  {{{
  <jx:attribute name="Name" value="Value"/>}}}
  
@@ -187, +205 @@

  <two>
      <jx:if test="${a == 'dd'}">
          <jx:attribute name="second" value="twoAttr"/>
-     </jx:if> 
+     </jx:if>
-     xyz 
+     xyz
  </two>
  <three foo="bar">
      <jx:attribute name="foo2" value="bar2"/>
@@ -199, +217 @@

  {{{
  <jx:set var="a" value="cd"/>
  <two>
-     xyz 
+     xyz
  </two>
  <three foo="bar" foo2="bar2" cd="cd">
      <abc>def</abc>
@@ -210, +228 @@

  This section describes some advanced options.
  
  === Caching ===
- It is possible for cocoon to cache output of this generator. In order to do so you need
to provide two pieces of information: the key under which to register the cached response
object in the cache and an object that describes the validity of the cached contents. 
+ It is possible for cocoon to cache output of this generator. In order to do so you need
to provide two pieces of information: the key under which to register the cached response
object in the cache and an object that describes the validity of the cached contents.
  
  '''''Note: This feature is experimental and only available in the cocoon 2.2.0-dev branch
in CVS'''''
  ==== jx:cache-key ====
@@ -266, +284 @@

  ==== Heavy business object instantiation ====
  Even though [:JXTemplateGenerator] caches the view data it does not mean the controller
will know about that. If your script contains heavy calculations or database operations this
is what you can do (based on: http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=108617011419745&w=2)
  
- If your business object takes an age to instantiate, and you can decide 
+ If your business object takes an age to instantiate, and you can decide
- whether or not to instantiate it based upon request parameters, then 
+ whether or not to instantiate it based upon request parameters, then
  wrap it in a lighter component that does (in pseudocode):
  
  {{{
@@ -283, +301 @@

  }
  }}}
  
- Then, in your jxt, you use {{{jx:cache-validity="${lightObject.getValidity()}"}}} construct,
and then later in 
+ Then, in your jxt, you use {{{jx:cache-validity="${lightObject.getValidity()}"}}} construct,
and then later in
- your jxt, you access your heavy object with 
+ your jxt, you access your heavy object with
- {{{#{/lightObject/HeavyObject/property1} }}}. This latter expression will only 
+ {{{#{/lightObject/HeavyObject/property1} }}}. This latter expression will only
  be invoked if the page is not cached.
  

Mime
View raw message