You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Ron McNulty <rm...@xtra.co.nz> on 2007/07/30 12:29:12 UTC

Nested repeaters and binding

Hi All

I have a requirement to nest repeaters as follows:

A summary page displays a list of customers.
Each customer has a list of current orders.

I want to list the companies, each having a table of orders.  I am using the 
binding framework to display the page. The current requirement is read only, 
but I suspect that the correct answer will cover editable fields as well.

Does anyone have an example on exactly how to do this? A search of the 
Cocoon site suggests that this is possible, but does not give a definitive 
example. What I need is XML snippets from a sample page_template.xml, 
page.xml and page_bind.xml files.

Any help much appreciated.

Regards

Ron 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: Nested repeaters and binding

Posted by Oliver Scheel <ol...@wazap.de>.
Hi Ron,

I also searched a lot of time and found an example in the cocoon(2.1.10) 
distribution (heavy-binding.xml).

Here is a concrete example (using beans as data model):

definition:
...
<fd:repeater id="customers">
    <fd:label><i18n:text>customers</i18n:text>:</fd:label>
    <fd:widgets>
       
        <fd:output id="customerId">
            <fd:datatype base="integer"/>
        </fd:output>
       
        <!-- the nested repeater definition -->
        <fd:repeater id="orders">
            <fd:label><i18n:text>orders</i18n:text></fd:label>
            <fd:widgets>
                <fd:output id="orderId">
                    <fd:datatype base="integer"/>
                </fd:output>
               
                <!-- additional order fields -->
            </fd:widgets>
        </fd:repeater>
       
        <!-- additional customer fields -->
    </fd:widgets>
</fd:repeater>
...

binding:

...
<!-- suppose you have a data model bean with a method named 
'getCustomers()' that returns a collection of Customers -->
<fb:repeater id="customers" parent-path="." row-path="customers">
    <fb:identity>
       <fb:value id="customerId" path="id" />
    </fb:identity>
    <fb:on-bind>
       <!-- suppose your data model bean 'Customer' has a method named 
'getOrders()' that returns a collection of Orders -->
       <fb:repeater id="orders" parent-path="." row-path="orders">
          <fb:identity>
             <fb:value id="orderId" path="id" />
          </fb:identity>
       </fb:repeater>
    </fb:on-bind>
</fb:repeater>
...

template:

...
<ft:repeater id="customers">
    <div>
        <table>
            <jx:choose>
                <jx:when test="${repeater.getSize() == 0}">
                  <tr><td>no customers</td></tr>
               </jx:when>
           <jx:otherwise>
               <ft:repeater-rows>
                   <tr>
                      <td>
                         <ft:widget id="customerId"/>
                      </td>
                      <td>
                         <ft:repeater id="orders">
                             <!-- layout the nested repeater -->  
                         </ft:repeater>
                      </td>
                   </tr>
                </ft:repeater-rows>
            </jx:otherwise>
        </table>
    </div>
</ft:repeater>
...

> Hi All
>
> I have a requirement to nest repeaters as follows:
>
> A summary page displays a list of customers.
> Each customer has a list of current orders.
>
>   
> I want to list the companies, each having a table of orders. I am 
> using the binding framework to display the page. The current 
> requirement is read only, but I suspect that the correct answer will 
> cover editable fields as well. Does anyone have an example on exactly 
> how to do this? A search of the Cocoon site suggests that this is 
> possible, but does not give a definitive example. What I need is XML 
> snippets from a sample page_template.xml, page.xml and page_bind.xml 
> files.
> Any help much appreciated.
>
> Regards
>
>   
> Ron
-- 
Oliver Scheel
Software Engineer

Wazap AG
Karl-Liebknecht-Str. 5
D-10178 Berlin (Mitte)
E-Mail:  oliver.scheel@wazap.de
URL:     http://wazap.de / http://wazap.jp

Winner of the prestigious 2007 Red Herring Europe 100 award

Sitz:         Berlin (HRB 103534 B, Amtsgericht Berlin-Charlottenburg)
Vorstand:     Andreas Rührig (VV), Timo Meyer, Alexander Piutti, Philip
Gienandt
Aufsichtsrat: Martin Sinner (Vors.), Frank Böhnke, Florian Seubert, Markus Jorquera Imbernón


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org