crossley 2003/12/10 22:14:33
Modified: site/2.1/userdocs/flow jxtemplate.html jxtemplate.pdf
Log:
Unifying controller and view FOM.
Documented varStatus attribute of forEach.
Revision Changes Path
1.5 +182 -37 cocoon-site/site/2.1/userdocs/flow/jxtemplate.html
Index: jxtemplate.html
===================================================================
RCS file: /home/cvs/cocoon-site/site/2.1/userdocs/flow/jxtemplate.html,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- jxtemplate.html 13 Nov 2003 15:48:36 -0000 1.4
+++ jxtemplate.html 11 Dec 2003 06:14:33 -0000 1.5
@@ -305,13 +305,15 @@
</pre>
<p>Embedded Jexl expressions are contained in <span
class="codefrag">${}</span>.</p>
<p>Embedded JXPath expressions are contained in <span
class="codefrag">#{}</span>.</p>
-<p>The referenced objects may be Java Beans, DOM, JDOM, or JavaScript
objects
-from a Flowscript. In addition the following implicit objects are available
as
-both JXPath and Jexl variables in a template:</p>
+<p>The referenced objects may be Java Beans, DOM, or JavaScript objects
+from a Flowscript. In addition, a special <span
class="codefrag">cocoon</span> object providing access to the Cocoon <a
href="api.html#FOM">FOM</a> is available as
+both a JXPath and Jexl variable in a template.
+</p>
+<p>The <span class="codefrag">cocoon</span> object contains the following
properties:</p>
<dl>
<dt>
-<a href="../../../apidocs/org/apache/cocoon/environment/Request.html"><span
class="codefrag">org.apache.cocoon.environment.Request</span></a><span
class="codefrag"> request</span>
+<a href="api.html#request">request</a>
</dt>
<dd>
@@ -321,79 +323,117 @@
<dt>
<br>
-<a href="../../../apidocs/org/apache/cocoon/environment/Response.html"><span
class="codefrag">org.apache.cocoon.environment.Response</span></a><span
class="codefrag"> response</span>
+<a href="api.html#session">session</a>
</dt>
<dd>
-<br>The Cocoon response associated with the current request<br>
+<br>The user session associated with the current request<br>
</dd>
<dt>
<br>
-<a href="../../../apidocs/org/apache/cocoon/environment/Session.html"><span
class="codefrag">org.apache.cocoon.environment.Session</span></a><span
class="codefrag"> session</span>
+<a href="api.html#context">context</a>
</dt>
<dd>
-<br>The Cocoon session associated with the current request<br>
+<br>The Cocoon context associated with the current request<br>
</dd>
<dt>
<br>
-<a href="../../../apidocs/org/apache/cocoon/environment/Context.html"><span
class="codefrag">org.apache.cocoon.environment.Context</span></a><span
class="codefrag"> context</span>
+<span class="codefrag">parameters</span>
</dt>
<dd>
-<br>The Cocoon context associated with the current request<br>
+<br>A map containing the parameters passed to the generator in the
pipeline<br>
</dd>
-
<dt>
<br>
-<span
class="codefrag">org.apache.avalon.framework.parameter.Parameter[]</span><span
class="codefrag"> parameters</span>
+<a href="api.html#WebContinuation">continuation</a>
</dt>
<dd>
-<br>Any parameters passed to the generator in the pipeline<br>
+<br>The current Web Continuation from your Flowscript<br>
</dd>
</dl>
<p>
Jexl Example:</p>
<pre class="code">
-The content type of the current request is ${request.contentType}
+The content type of the current request is ${cocoon.request.contentType}
</pre>
<p>
JXPath Example:</p>
<pre class="code">
-The content type of the current request is #{$request/contentType}
+The content type of the current request is #{$cocoon/request/contentType}
</pre>
<p>
-The current Web Continuation from the Flowscript
-is also available as a variable named <span
class="codefrag">continuation</span>. You would
-typically access its <span class="codefrag">id</span>:</p>
+You would typically access the <span class="codefrag">id</span> of the Web
Continuation:</p>
<pre class="code">
-<form action="${continuation.id}">
+<form action="${cocoon.continuation.id}">
</pre>
-<p>You can also reach previous continuations by using the <span
class="codefrag">getParent()</span> function:</p>
+<p>You can also reach previous continuations via its <span
class="codefrag">parent</span> property:</p>
<pre class="code">
-<form action="${continuation.getParent().id}" >
+<form action="${cocoon.continuation.parent.id}" >
</pre>
<p>or using an XPath expression:</p>
<pre class="code">
-<form action="#{getParent($continuation)/id}" >
+<form action="#{$cocoon/continuation/parent/id}" >
</pre>
+<p>Deprecated Variables:</p>
+<p>The following variables are deprecated but still supported:</p>
+<dl>
+
+<dt>
+<a
href="../../../apidocs/org/apache/cocoon/environment/Request.html">org.apache.cocoon.environment.Request</a>
<span class="codefrag">request</span>
+</dt>
+
+<dd>
+<br>The current Cocoon request (deprecated: use <span
class="codefrag">cocoon.request</span> instead)<br>
+</dd>
+
+
+<dt>
+<a
href="../../../apidocs/org/apache/cocoon/environment/Session.html">org.apache.cocoon.environment.Session</a>
<span class="codefrag">session</span>
+</dt>
+
+<dd>
+<br>The current user session (deprecated: use <span
class="codefrag">cocoon.session</span> instead)<br>
+</dd>
+
+
+<dt>
+<a
href="../../../apidocs/org/apache/cocoon/environment/Context.html">org.apache.cocoon.environment.Context</a>
<span class="codefrag">context</span>
+</dt>
+
+<dd>
+<br>The current context (deprecated: use <span
class="codefrag">cocoon.context</span> instead)<br>
+</dd>
+
+
+<dt>
+<a
href="../../../apidocs/org/apache/cocoon/components/flow/WebContinuation.html">org.apache.cocoon.components.flow.WebContinuation</a>
<span class="codefrag">continuation</span>
+</dt>
+
+<dd>
+<br>The current Web Continuation (deprecated: use <span
class="codefrag">cocoon.continuation</span> instead)<br>
+</dd>
+
+</dl>
</div>
-<a name="N100F7"></a><a name="Tags"></a>
+
+<a name="N1013C"></a><a name="Tags"></a>
<h3>Tags</h3>
<div style="margin-left: 0 ; border: 2px">
<p>The JXTemplate Generator tags are defined in the namespace</p>
<pre class="code">
http://apache.org/cocoon/templates/jx/1.0
</pre>
-<a name="N10104"></a><a name="template"></a>
+<a name="N10149"></a><a name="template"></a>
<h4>template</h4>
<div style="margin-left: 0 ; border: 2px">
<p>The <span class="codefrag">template</span> tag defines a new template:</p>
@@ -402,9 +442,8 @@
body
</jx:template>
</pre>
-<p></p>
</div>
-<a name="N10116"></a><a name="import"></a>
+<a name="N10159"></a><a name="import"></a>
<h4>import</h4>
<div style="margin-left: 0 ; border: 2px"></div>
<p>The <span class="codefrag">import</span> tag allows you to include
another template within the current template. The content of the imported
template is compiled and will be executed in place of the <span
class="codefrag">import</span> tag:</p>
@@ -412,7 +451,7 @@
<jx:import uri="URI" [context="Expression"]/>
</pre>
<p>The Cocoon source resolver is used to resolve <span
class="codefrag">uri</span>. If <span class="codefrag">context</span> is
present, then its value is used as the context for evaluating the imported
template, otherwise the current context is used.</p>
-<a name="N10130"></a><a name="set"></a>
+<a name="N10173"></a><a name="set"></a>
<h4>set</h4>
<div style="margin-left: 0 ; border: 2px">
<p>The <span class="codefrag">set</span> tag creates a local alias of an
object. The <span class="codefrag">var</span> attribute specifies the name of a
variable to assign the object to. The <span class="codefrag">value</span>
attribute specifies the object (defaults to <span class="codefrag">body</span>
if not present):</p>
@@ -434,7 +473,7 @@
</pre>
<p></p>
</div>
-<a name="N10166"></a><a name="if"></a>
+<a name="N101A9"></a><a name="if"></a>
<h4>if</h4>
<div style="margin-left: 0 ; border: 2px">
<p>The <span class="codefrag">if</span> tag allows the conditional execution
of its body
@@ -459,7 +498,7 @@
</pre>
<p></p>
</div>
-<a name="N1018E"></a><a name="choose"></a>
+<a name="N101D1"></a><a name="choose"></a>
<h4>choose</h4>
<div style="margin-left: 0 ; border: 2px">
<p>The <span class="codefrag">choose</span> tag performs conditional block
execution by its
@@ -503,7 +542,7 @@
</pre>
<p></p>
</div>
-<a name="N101C8"></a><a name="out"></a>
+<a name="N1020B"></a><a name="out"></a>
<h4>out</h4>
<div style="margin-left: 0 ; border: 2px">
<p>The <span class="codefrag">out</span> tag evaluates an expression and
outputs
@@ -521,13 +560,14 @@
</pre>
<p></p>
</div>
-<a name="N101EB"></a><a name="forEach"></a>
+<a name="N1022E"></a><a name="forEach"></a>
<h4>forEach</h4>
<div style="margin-left: 0 ; border: 2px">
<p>The <span class="codefrag">forEach</span> tag allows you to iterate over
a collection
of objects:</p>
<pre class="code">
-<jx:forEach [var="Name"] [items="Expression"] [begin="NumExpr"]
[end="NumExpr"] [step="NumExpr"]>
+<jx:forEach [var="Name"] [varStatus="Name"] [items="Expression"]
+ [begin="NumExpr"] [end="NumExpr"] [step="NumExpr"]>
body
</jx:forEach>
</pre>
@@ -537,6 +577,111 @@
attribute specifies the item to end with (<span class="codefrag">0</span> =
first item,
<span class="codefrag">1</span> = second item, ...). If unspecified it
defaults to the last item in the list. Every <span class="codefrag">step</span>
items are
processed (defaults to <span class="codefrag">1</span> if <span
class="codefrag">step</span> is absent). Either <span
class="codefrag">items</span> or both <span class="codefrag">begin</span> and
<span class="codefrag">end</span> must be present.</p>
+<p>
+If the <span class="codefrag">varStatus</span> attribute is present a
variable will be created to hold information about the current loop status. The
variable named by the <span class="codefrag">varStatus</span> attribute will
hold a reference to an object with the following properties:
+</p>
+<table class="ForrestTable" cellspacing="1" cellpadding="4">
+
+<tr>
+
+<td colspan="1" rowspan="1">
+ Property:
+ </td>
+ <td colspan="1" rowspan="1">
+ Description:
+ </td>
+
+</tr>
+
+<tr>
+
+<td colspan="1" rowspan="1">
+ current
+ </td>
+ <td colspan="1" rowspan="1">
+ The item from the collection for the current round of iteration
+ </td>
+
+</tr>
+
+<tr>
+
+<td colspan="1" rowspan="1">
+ index
+ </td>
+ <td colspan="1" rowspan="1">
+ The zero-based index for the current round of iteration
+ </td>
+
+</tr>
+
+<tr>
+
+<td colspan="1" rowspan="1">
+ count
+ </td>
+ <td colspan="1" rowspan="1">
+ The one-based count for the current round of iteration
+ </td>
+
+</tr>
+
+<tr>
+
+<td colspan="1" rowspan="1">
+ first
+ </td>
+ <td colspan="1" rowspan="1">
+ True if this is the first round of iteration
+ </td>
+
+</tr>
+
+<tr>
+
+<td colspan="1" rowspan="1">
+ last
+ </td>
+ <td colspan="1" rowspan="1">
+ True if this is the last round of iteration
+ </td>
+
+</tr>
+
+<tr>
+
+<td colspan="1" rowspan="1">
+ begin
+ </td>
+ <td colspan="1" rowspan="1">
+ The value of the <span class="codefrag">begin</span> attribute
+ </td>
+
+</tr>
+
+<tr>
+
+<td colspan="1" rowspan="1">
+ end
+ </td>
+ <td colspan="1" rowspan="1">
+ The value of the <span class="codefrag">end</span> attribute
+ </td>
+
+</tr>
+
+<tr>
+
+<td colspan="1" rowspan="1">
+ step
+ </td>
+ <td colspan="1" rowspan="1">
+ The value of the <span class="codefrag">step</span> attribute
+ </td>
+
+</tr>
+
+</table>
<p>An alternate form of <span class="codefrag">forEach</span> is supported
for convenience when using XPath (since you can specify the selection criteria
for the collection using XPath itself):</p>
<pre class="code">
<jx:forEach select="XPathExpression">
@@ -561,7 +706,7 @@
</pre>
<p></p>
</div>
-<a name="N10253"></a><a name="formatNumber"></a>
+<a name="N10320"></a><a name="formatNumber"></a>
<h4>formatNumber</h4>
<div style="margin-left: 0 ; border: 2px">
<p>
@@ -595,7 +740,7 @@
The <span class="codefrag">groupingUsed</span> attribute takes a <span
class="codefrag">Boolean</span> value and controls whether digits before the
decimal point are grouped. For example, in English-language locales, large
numbers have their digits grouped by threes, with each set of three delimited
by a comma. Other locales delimit such groupings with a period or a space. The
default value for this attribute is <span class="codefrag">true</span>.
</p>
</div>
-<a name="N102B2"></a><a name="formatDate"></a>
+<a name="N1037F"></a><a name="formatDate"></a>
<h4>formatDate</h4>
<div style="margin-left: 0 ; border: 2px">
<p>The <span class="codefrag">formatDate</span> tag provides facilities to
format Date values:</p>
@@ -611,16 +756,16 @@
The <span class="codefrag">type</span> attribute indicates which fields of
the specified <span class="codefrag">Date</span> instance are to be displayed,
and should be either "time", "date", or "both". The default value for this
attribute is "date", so if no <span class="codefrag">type</span> attribute is
present, the <span class="codefrag">formatDate</span> tag -- true to its name
-- will only display the date information associated with the <span
class="codefrag">Date</span> instance, specified using the tag's value
attribute.
</p>
<p>
-The <span class="codefrag">dateStyle</span> and <span
class="codefrag">timeStyle</span> attributes indicate how the date and time
information should be formatted, respectively. Valid styles are "default",
"short", "medium", "long", and "full". The default value is, naturally,
"default", indicating that a locale-specific style should be used. The
semantics for the other four style values are as defined by the
@link{java.text.DateFormat} class.
+The <span class="codefrag">dateStyle</span> and <span
class="codefrag">timeStyle</span> attributes indicate how the date and time
information should be formatted, respectively. Valid styles are "default",
"short", "medium", "long", and "full". The default value is, naturally,
"default", indicating that a locale-specific style should be used. The
semantics for the other four style values are as defined by the
java.text.DateFormat class.
</p>
<p>
-Rather than relying on the built-in styles, you can use the pattern
attribute to specify a custom style. When present, the value of the pattern
attribute should be a pattern string following the conventions of the
@link{java.text.SimpleDateFormat} class. These patterns are based on replacing
designated characters within the pattern with corresponding date and time
fields. For example, the pattern MM/dd/yyyy indicates that two-digit month and
date values and a four-digit year value should be displayed, separated by
forward slashes.
+Rather than relying on the built-in styles, you can use the pattern
attribute to specify a custom style. When present, the value of the pattern
attribute should be a pattern string following the conventions of the
java.text.SimpleDateFormat class. These patterns are based on replacing
designated characters within the pattern with corresponding date and time
fields. For example, the pattern MM/dd/yyyy indicates that two-digit month and
date values and a four-digit year value should be displayed, separated by
forward slashes.
</p>
<p>
If the <span class="codefrag">var</span> attribute is specified, then a
String value containing the formatted date is assigned to the named variable.
Otherwise, the <span class="codefrag">formatDate</span> tag will write out the
formatting results.
</p>
</div>
-<a name="N102F6"></a><a name="macro"></a>
+<a name="N103C3"></a><a name="macro"></a>
<h4>macro</h4>
<div style="margin-left: 0 ; border: 2px">
<p>The <span class="codefrag">macro</span> tag allows you define a new
custom tag.</p>
1.5 +284 -196 cocoon-site/site/2.1/userdocs/flow/jxtemplate.pdf
<<Binary file>>