cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@cocoon.zones.apache.org
Subject [DAISY] Updated: Repeater widget
Date Mon, 17 Oct 2005 20:31:30 GMT
A document has been updated:

http://cocoon.zones.apache.org/daisy/documentation/496.html

Document ID: 496
Branch: main
Language: default
Name: Repeater widget (unchanged)
Document Type: Document (unchanged)
Updated on: 10/17/05 8:31:24 PM
Updated by: Bruno Dumon

A new version has been created, state: publish

Parts
=====
Content
-------
This part has been updated.
Mime type: text/xml (unchanged)
File name:  (unchanged)
Size: 4461 bytes (previous version: 1647 bytes)
Content diff:
(5 equal lines skipped)
    <p>An fd:repeater widget is a widget that repeats a number of other widgets. It
    can be used to create e.g. tables, repeating subforms, etc.</p>
    
--- <h1>Configuration</h1>
+++ <h1>Definition</h1>
    
    <pre>&lt;fd:repeater id="..." initial-size="..." min-size="..." max-size="..."
state="..."&gt;
      &lt;fd:label&gt;...&lt;/fd:label&gt;
(28 equal lines skipped)
    <p>For a description of the other elements, see the <a href="daisy:481">field
    widget</a>.</p>
    
--- <p class="note">The Forms Template Transformer has specific support for
--- specifying a template to use to render each of the rows of a repeater widget.
--- See the CForms samples for an example on how to use this.</p>
+++ <h1>Template</h1>
    
+++ <h2>Before Cocoon 2.1.8</h2>
+++ 
+++ <p>The following elements are available for formatting a repeater in a template:
+++ </p>
+++ 
+++ <ul>
+++ <li><tt>ft:repeater-widget</tt>: the content of this element is a template
that
+++ will be executed for each row in the repeater</li>
+++ <li><tt>ft:repeater-widget-label</tt>: this element inserts the label
of a
+++ widget contained by the repeater (to be used outside of ft:repeater-widget)</li>
+++ <li><tt>ft:repeater-size</tt>: inserts an element <tt>&lt;fi:repeater-size
+++ id="..." size="..."/&gt;</tt> containing the size (number of rows) of the
+++ repeater. This element is only needed when the form model is not stored in the
+++ server (thus when operating stateless). In that case the size of the repeater
+++ must be communicated on each round-trip.</li>
+++ </ul>
+++ 
+++ <p>An example that formats a repeater with ID "myrepeater", having two child
+++ widgets with IDs "field1" and "field2",  as a table:</p>
+++ 
+++ <pre>&lt;table&gt;
+++   &lt;tbody&gt;
+++     &lt;tr&gt;
+++       &lt;th&gt;&lt;ft:repeater-widget-label id="myrepeater" widget-id="field1"/&gt;&lt;/th&gt;
+++       &lt;th&gt;&lt;ft:repeater-widget-label id="myrepeater" widget-id="field2"/&gt;&lt;/th&gt;
+++     &lt;/tr&gt;
+++     &lt;ft:repeater-widget id="myrepeater"&gt;
+++       &lt;tr&gt;
+++         &lt;td&gt;&lt;ft:widget id="field1"/&gt;&lt;/td&gt;
+++         &lt;td&gt;&lt;ft:widget id="field2"/&gt;&lt;/td&gt;
+++       &lt;/tr&gt;
+++     &lt;/ft:repeater-widget&gt;
+++   &lt;/tbody&gt;
+++ &lt;/table&gt;
+++ </pre>
+++ 
+++ <h2>From Cocoon 2.1.8</h2>
+++ 
+++ <p>Cocoon 2.1.8 introduced a slightly extended manner to format repeaters, which
+++ is required when using the new <a href="daisy:750">Ajax</a> features. Instead
of
+++ one ft:repeater-widget element, it uses two elements:</p>
+++ 
+++ <ul>
+++ <li><tt>ft:repeater</tt>: encloses the entire formatted repeater</li>
+++ <li><tt>ft:repeater-rows</tt>: encloses the repeating part</li>
+++ </ul>
+++ 
+++ <p>Below is the same example as above using the new syntax. In addition, it
+++ illustrates the availability of a "repeaterLoop" variable inside the
+++ ft:repeater-rows element.</p>
+++ 
+++ <pre>&lt;ft:repeater id="myrepeater"&gt;
+++   &lt;table&gt;
+++     &lt;tbody&gt;
+++       &lt;tr&gt;
+++         &lt;th&gt;&lt;ft:repeater-widget-label widget-id="field1"/&gt;&lt;/th&gt;
+++         &lt;th&gt;&lt;ft:repeater-widget-label widget-id="field2"/&gt;&lt;/th&gt;
+++       &lt;/tr&gt;
+++       &lt;ft:repeater-rows&gt;
+++         &lt;tr class="forms-row-${repeaterLoop.index % 2}"&gt;
+++           &lt;td&gt;&lt;ft:widget id="field1"/&gt;&lt;/td&gt;
+++           &lt;td&gt;&lt;ft:widget id="field2"/&gt;&lt;/td&gt;
+++         &lt;/tr&gt;
+++       &lt;/ft:repeater-rows&gt;
+++     &lt;/tbody&gt;
+++   &lt;/table&gt;
+++ &lt;/ft:repeater&gt;
+++ </pre>
+++ 
+++ <h2>Tips</h2>
+++ 
+++ <p>When using JXTemplate, it is possible to test if a repeater is empty and show
+++ something else in that case. For example:</p>
+++ 
+++ <pre>&lt;jx:choose&gt;
+++   &lt;jx:when test="${widget.getChild('myrepeater').getSize() == 0}"&gt;
+++     No items yet.
+++   &lt;/jx:when&gt;
+++   &lt;jx:otherwise&gt;
+++    [... normal repeater formatting here ...]
+++   &lt;/jx:otherwise&gt;
+++ &lt;/jx:choose&gt;
+++ </pre>
+++ 
    </body>
    </html>


Fields
======
no changes

Links
=====
no changes

Custom Fields
=============
no changes

Collections
===========
no changes

Mime
View raw message