On Nov 29, 2005, at 3:07 PM, Michael Campbell wrote:

"Patrick Casey" <[EMAIL PROTECTED]> writes:

<table>
        <span jwcid="@Foreach" source="ognl:list" value="ognl:currentValue"
element="tr">
                <td>
                        <span jwcid="@Insert" value="ognl:currentValue.foo"
/>
                </td>
        </span>
</table>

Thanks Patrick.  I don't know what I'm looking at yet there, but I
have both Howard's and Kent's books, so I know what to look FOR...


This actually doesn't do what you want. This takes a list of elements (the source) and prints each one in a separate cell in a single long row.

You wanted a way to introduce new rows each n elements. You'd do that like this in your .html file:

<table>
<tr>
<span jwcid="@Foreach" source="ognl:list" value="ognl:currentValue" index="ognl:i">

<span jwcid="@Conditional" condition="ognl:i + 1 % n == 0">
</tr><tr>
</span>

<td>
        <span jwcid="@Insert" value="ognl:currentValue.displayValue" />
</td>

</tr>
</span>

In your .page file, you need:

<property-specification name="list" type="java.util.List" />
<property-specification name="currentValue" type="your.package.ClassName" />
<property-specification name="i" type="int" />

So, what this does is creates a table and a row and loops over each of the values in the list, setting currentValue to each one in turn and updating the index variable i.

The @Conditional checks to see if i + 1 % n (you should stick in some real number there or have another property for n) is 0, and ends the current row and starts a new one if that's the case. (I think this is buggy. You may get a blank row at the end.)

The @Insert replaces itself with the output of the getDisplayValue() method of the currentValue object which is, by virtue of the two tags, the contents of a table cell.

Given all of that, it may be easier to use the ContribTable component, where you can specify the size of the table and which element should go where, but it's do-able.

Todd

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

Reply via email to