struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ted Husted" <news....@husted.com>
Subject RE: problems with the logic:iterate tag
Date Fri, 26 Jan 2001 15:56:37 GMT
On 1/26/2001 at 2:18 PM Florian Zwerina wrote:
> but what I really like to do is the following (our web designer would
appreciate it !):

For 

<jsp:useBean id="item" scope="page" class="com.mycomp.SomeData"/>

<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>

Try 

<jsp:useBean id="item" scope="page" class="com.mycomp.SomeData"/>

<table>
<logic:iterate name="item" id="list" property="someList">
  <tr>
    <td align="left">
      <bean:write name="list" property="name"/>
    </td>
    <td align="left">
      <bean:write name="list" property="manager"/>
    </td>
  </tr>
</logic:iterate>

Or, maybe just 

<logic:iterate name="item" id="list">

The real point being that the "id" property is what you want to call
the object in the given scope. So when you hand the object off from
useBean to iterate, the useBean's "id" becomes iterate's "name", and
then you pick some other "id" for the instance of each thing iterated.
(whewww.)

HTH, and let me know if it doesn't. Iterate's can be tricky at first. 

*********** REPLY SEPARATOR  ***********

On 1/26/2001 at 2:18 PM Florian Zwerina wrote:

I have a problem with the <logic:iterate > tag

the following piece of 'code' works ok
(therfore I know I am doing nothing wrong on the Controller/Model
side):

<jsp:useBean id="item" scope="page" class="com.mycomp.SomeData"/>

<table>
<%
	Iterator it =
((Collection)session.getAttribute("someList")).iterator();
	while (it.hasNext()){
		pageContext.setAttribute("item",it.next());
%>
  <tr>
    <td align="left">
      <bean:write name="item" property="name"/>
    </td>
    <td align="left">
      <bean:write name="item" property="manager"/>
    </td>
    <td align="left">
      <bean:write name="item" property="ID"/>
    </td>
  </tr>
<% }  %>
</table>

but what I really like to do is the following
(our web designer would appreciate it !):

<jsp:useBean id="item" scope="page" class="com.mycomp.SomeData"/>

<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>

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 ?


-- 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/



Mime
View raw message