Ugo Cei wrote:
Here's a simple problem for which I cannot seem to find a simple solution (or any solution at all). I hope someone here can help me.

I have a Collection of Java beans. Each bean has a couple of properties: "id" (Integer) and "name" (String).

I also have a form with a repeater:

    <fd:repeater id="current">
      <fd:widgets>
        <fd:output name="id" id="id">
          <fd:datatype base="integer"/>
        </fd:output>
        <fd:output id="name">
          <fd:label>Name</fd:label>
          <fd:datatype base="string"/>
        </fd:output>
        <fd:booleanfield id="select">
          <fd:label>Select</fd:label>
        </fd:booleanfield>
      </fd:widgets>
    </fd:repeater>

The repeater is bound to the collection:

  <fb:repeater id="current" parent-path="." row-path="current">
    <fb:identity>
      <fb:value id="id" path="@id" direction="load"/>
    </fb:identity>
    <fb:on-bind>
      <fb:value id="name" path="name" direction="load"/>
    </fb:on-bind>
  </fb:repeater>

As you can see, data is mostly read-only. I am just interested in the value of the "select" field for selecting some rows to be further processed.

I also created a template for displaying the repeater as a two-column table. Column 1 is for the "select" widget, whereas column 2 shoud display the "name" property. That was easy.

The next requirement is for each "name" to be a link to an URL which depends on the value of the corresponding "id". Something like:

    <ft:repeater-widget id="current">
      <tr>
        <td><ft:widget id="select"/></td>
        <td>
          <a href="/base/[INSERT-ID-HERE]"><ft:widget id="name"/></a>
        </td>
      </tr>
    </ft:repeater-widget>

Now the question is: what would be the easiest way to put the "id" property of the bean bound to the current row in place of the "[INSERT-ID-HERE]" string?

You have to use the cforms macro library to get the id:

...
<jx:import uri="resource://org/apache/cocoon/forms/generation/jx-macros.xml"/>
...

<ft:repeater-widget id="current">
  <tr>
    <td><ft:widget id="select"/></td>
    <td>
<a href="/base/${repeater.getRow(repeaterLoop.index).lookupWidget('id').value">
      <ft:widget id="name"/></a>
    </td>
  </tr>
</ft:repeater-widget>

--
Reinhard Pötz Independent Consultant, Trainer & (IT)-Coach
{Software Engineering, Open Source, Web Applications, Apache Cocoon}

                                       web(log): http://www.poetz.cc
--------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to