You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Florian Zwerina <fl...@update.com> on 2001/01/26 10:45:16 UTC
problems with the logic:iterate tag
Hi !
I have a problem with the <logic:iterate > tag
the following piece of 'code' works ok=20
(so I know I=B4m doing nothing wrong on the Controller/Model side):
<jsp:useBean id=3D"item" scope=3D"page" class=3D"com.mycomp.SomeData"/>
<table>
<%=09
Iterator it =3D
((Collection)session.getAttribute("someList")).iterator();
while (it.hasNext()){
pageContext.setAttribute("item",it.next());
%>
<tr>
<td align=3D"left">
<bean:write name=3D"item" property=3D"name"/>
</td>
<td align=3D"left">
<bean:write name=3D"item" property=3D"manager"/>
</td>
<td align=3D"left">
<bean:write name=3D"item" property=3D"ID"/>
</td>
</tr>
<% } %>
</table>
but what I really like to do is
(our web designer would appreciate it !):
<jsp:useBean id=3D"item" scope=3D"page" class=3D"com.mycomp.SomeData"/>
<table>
<logic:iterate id=3D"item" name=3D"someList">
<tr>
<td align=3D"left">
<bean:write name=3D"item" property=3D"name"/>
</td>
<td align=3D"left">
<bean:write name=3D"item" property=3D"manager"/>
</td>
</tr>
</logic:iterate>
but with the second approach the table is always empty...
am I too stupid to use the iterate tag ?
or is something else wrong with my approach ?
pleas help !
Regards
flo
Re: problems with the logic:iterate tag
Posted by Ted Husted <ne...@husted.com>.
Could you submit your example as an attachment? In my mail reader at
least, some of the control characters were converted to ASCII, and it
is difficult to read.
*********** REPLY SEPARATOR ***********
On 1/26/2001 at 10:45 AM Florian Zwerina wrote:
Hi !
I have a problem with the <logic:iterate > tag
the following piece of 'code' works ok=20
(so I know I=B4m doing nothing wrong on the Controller/Model side):
<jsp:useBean id=3D"item" scope=3D"page" class=3D"com.mycomp.SomeData"/>
<table>
<%=09
Iterator it =3D
((Collection)session.getAttribute("someList")).iterator();
while (it.hasNext()){
pageContext.setAttribute("item",it.next());
%>
<tr>
<td align=3D"left">
<bean:write name=3D"item" property=3D"name"/>
</td>
<td align=3D"left">
<bean:write name=3D"item" property=3D"manager"/>
</td>
<td align=3D"left">
<bean:write name=3D"item" property=3D"ID"/>
</td>
</tr>
<% } %>
</table>
but what I really like to do is
(our web designer would appreciate it !):
<jsp:useBean id=3D"item" scope=3D"page" class=3D"com.mycomp.SomeData"/>
<table>
<logic:iterate id=3D"item" name=3D"someList">
<tr>
<td align=3D"left">
<bean:write name=3D"item" property=3D"name"/>
</td>
<td align=3D"left">
<bean:write name=3D"item" property=3D"manager"/>
</td>
</tr>
</logic:iterate>
but with the second approach the table is always empty...
am I too stupid to use the iterate tag ?
or is something else wrong with my approach ?
pleas help !
Regards
flo
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 425-0252; Fax 716 223-2506.
-- http://www.husted.com/about/struts/
Re: problems with the logic:iterate tag
Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
There was a bug in the nightly build versions through early January -- the
<logic:iterate> tag was not exposing the variable name you specified with "id"
to the rest of the page. This has been fixed, AFAIK. Can you please try this
with a very recent nightly build?
For the record, where "someList" is a bean that implements Collection, the
following code should work correctly:
<table>
<logic:iterate id="item" name="someList">
<tr>
<td align="left">
<bean:write name="item" property="name"/>
</td>
<td align="left">
<bean:write name="item" property="manager"/>
</td>
</tr>
</logic:iterate>
Craig
Florian Zwerina wrote:
> Hi !
>
> I have a problem with the <logic:iterate > tag
>
> the following piece of 'code' works ok=20
> (so I know I=B4m doing nothing wrong on the Controller/Model side):
>
> <jsp:useBean id=3D"item" scope=3D"page" class=3D"com.mycomp.SomeData"/>
>
> <table>
> <%=09
> Iterator it =3D
> ((Collection)session.getAttribute("someList")).iterator();
> while (it.hasNext()){
> pageContext.setAttribute("item",it.next());
> %>
> <tr>
> <td align=3D"left">
> <bean:write name=3D"item" property=3D"name"/>
> </td>
> <td align=3D"left">
> <bean:write name=3D"item" property=3D"manager"/>
> </td>
> <td align=3D"left">
> <bean:write name=3D"item" property=3D"ID"/>
> </td>
> </tr>
> <% } %>
> </table>
>
> but what I really like to do is
> (our web designer would appreciate it !):
>
> <jsp:useBean id=3D"item" scope=3D"page" class=3D"com.mycomp.SomeData"/>
>
> <table>
> <logic:iterate id=3D"item" name=3D"someList">
> <tr>
> <td align=3D"left">
> <bean:write name=3D"item" property=3D"name"/>
> </td>
> <td align=3D"left">
> <bean:write name=3D"item" property=3D"manager"/>
> </td>
> </tr>
> </logic:iterate>
>
> but with the second approach the table is always empty...
>
> am I too stupid to use the iterate tag ?
> or is something else wrong with my approach ?
>
> pleas help !
>
> Regards
>
> flo