You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Vollnhofer Bernhard <Be...@itsv.at> on 2010/06/17 15:58:19 UTC

Iterating over a Collection and creating a for each entry of it

Hi!

Is something like the following snippet possible to do?

<c:forEach items="${MyForm.list}" var="entry">
    <tr>
        <td>${entry.name}</td>
        <td>${entry.forced}</td>
        <html:checkbox property="entry.checked" />
    </tr>
</c:forEach>

Of course this code won't do it, but I hope you're getting my idea. I'd like to iterate over a collection and create a <html:checkbox /> for every item in it. This checkbox should set the "checked"-variable of an entry. Is such a feat possible?

Thank you

Bernhard



Re: Iterating over a Collection and creating a for each entry of it

Posted by Alex Rodriguez Lopez <al...@flordeutopia.pt>.
http://struts.apache.org/2.x/docs/checkboxlist.html

> Hi!
>
> Is something like the following snippet possible to do?
>
> <c:forEach items="${MyForm.list}" var="entry">
>      <tr>
>          <td>${entry.name}</td>
>          <td>${entry.forced}</td>
>          <html:checkbox property="entry.checked" />
>      </tr>
> </c:forEach>
>
> Of course this code won't do it, but I hope you're getting my idea. I'd like to iterate over a collection and create a<html:checkbox />  for every item in it. This checkbox should set the "checked"-variable of an entry. Is such a feat possible?
>
> Thank you
>
> Bernhard
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


AW: Iterating over a Collection and creating a for each entry of it

Posted by Vollnhofer Bernhard <Be...@itsv.at>.
I've got it working now. I'm using:

<c:forEach items="${MyForm.list}" var="entry " varStatus="status">
    <html:checkbox property="list[${status.count-1}].checked" />
</c:forEach>

-----Ursprüngliche Nachricht-----
Von: Vollnhofer Bernhard [mailto:Bernhard.Vollnhofer@itsv.at] 
Gesendet: Donnerstag, 17. Juni 2010 15:58
An: user@struts.apache.org
Betreff: Iterating over a Collection and creating a <html:checkbox /> for each entry of it

Hi!

Is something like the following snippet possible to do?

<c:forEach items="${MyForm.list}" var="entry">
    <tr>
        <td>${entry.name}</td>
        <td>${entry.forced}</td>
        <html:checkbox property="entry.checked" />
    </tr>
</c:forEach>

Of course this code won't do it, but I hope you're getting my idea. I'd like to iterate over a collection and create a <html:checkbox /> for every item in it. This checkbox should set the "checked"-variable of an entry. Is such a feat possible?

Thank you

Bernhard



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org