I've used similar solutions to what Andreas suggested.
Another option might be to break your collection into a collection
of collections, and use nested looping. The template is a bit cleaner;
the code is a bit uglier. :)
Robert
Andreas Andreou wrote:
> Ben Wong wrote:
>
>> Hi everyone,
>>
>>
>>
>> I have been tried to get Tapestry to display radio buttons in two columns
>> like below. The radio buttons are dynamically generated from a
>> collection.
>> Naturally, I tried using a ForEach component looping through the
>> collection.
>> At first, I tried having the ForEach component step through 2 at a
>> time but
>> that didn't work. Unless I am wrong, ForEach does not have an
>> "increment by
>> n" option. Finally, I tried simply checking whether it is the first or
>> second radio button. If it is the first one, then I put in the <tr> tag.
>> If it is the second, I put in the </tr> tag. The problem is I cannot
>> seem
>> to get Tapestry to take it. Apparently, you cannot just stick a
>> closing tag
>> </tr> within a <span> tag without the <tr> tag.
>
>
> That's true...
>
> But, you can do a simple hack.
> In the first conditional span, include
> <span jwcid="@Insert" raw="true" value="ognl:trOpen"/>
> , in the second
> <span jwcid="@Insert" raw="true" value="ognl:trClose"/>
> and in the java source add
>
> public String getTrOpen() { return "<tr>";}
> public String getTrClose() { return "</tr>";}
>
> It's a bit ugly, I know, but it works...
>
>> My non-working code is as
>> follows:
>>
>>
>>
>> <table>
>>
>> <form jwcid="@Form">
>>
>> <span jwcid="@RadioGroup" selected="selectedRejectedReasonCode">
>>
>> <span jwcid="@Foreach" source="rejectedReasons"
>> value="rejectedReason">
>>
>> <span jwcid="@Conditional"
>> condition="ognl:isOddRejectedReasonIndex()">
>>
>> <tr>
>>
>> </span>
>> <td>
>> <input type="radio" jwcid="rejectedReasonRadio"/><span
>> jwcid="rejectedReasonRadioDescription"> Previously Approved</span><br/>
>>
>> </td>
>>
>> <span jwcid="@Conditional"
>> condition="ognl:isOddRejectedReasonIndex()">
>>
>> </tr>
>>
>> </span>
>>
>> </span>
>>
>> </span>
>>
>> </form>
>>
>> </table>
>>
>>
>>
>> Anybody has a better recommendation as to how to do something like
>> this. I
>> am sure most of you have done this a million times before, but for the
>> life
>> of me, I cannot figure it out.
>>
>>
>> Thanks,
>>
>> Ben Wong
>>
>>
>>
>>
>>
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]