You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Matt Raible <ma...@yahoo.com> on 2001/06/07 17:29:22 UTC

Is this possible with Struts?

I have an iteration of Beans and I want to list through the iteration,
extract the beans and get the properties on each bean.  Is this possible?

Example code:



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


Re: Is this possible with Struts?

Posted by Ted Husted <hu...@apache.org>.
< 
http://jakarta.apache.org:8080/jyve-faq/Turbine/screen/DisplayQuestionAnswer/action/SetAll/project_id/2/faq_id/36/topic_id/207/question_id/821 

>

Re: Is this possible with Struts?

Posted by Matt Raible <ma...@yahoo.com>.
Thanks - worked like a charm!

I have another question now:

I am now trying to setup my list so it alternates row backgrounds as it writes the list.  Below is how I can do it with scriplets, but I'd rather use Struts to do this - any ideas?

<% 
int rowNum = 0;
%>
<logic:iterate id="list" name="beans">
<%
rowNum++;
                            
// Set tdClassName for different colored rows
String tdClassName = "";
if ((rowNum % 2) > 0) {
    tdClassName = "tableRowNormal";
} else {
    tdClassName = "tableRowAlternate";
}
%>
<tr> 
    <td class="<%=tdClassName%>"><bean:write name="list" property="name"/></td>
    <td class="<%=tdClassName%>"><bean:write name="list" property="description"/></td>
    <td class="<%=tdClassName%>"><bean:write name="list" property="status"/></td>
</logic:iterate>
</tr>



  ----- Original Message ----- 
  From: David Winterfeldt 
  To: struts-user@jakarta.apache.org 
  Sent: Thursday, June 07, 2001 10:39 AM
  Subject: Re: Is this possible with Struts?


  This calls getLastName() on each object in the list.

  <logic:iterate id="results" name="myList">
     <bean:write name="results" property="lastName"/><br>

  </logic:iterate>


    Matt Raible <ma...@yahoo.com> wrote: 

    I have an iteration of Beans and I want to list through the iteration,
    extract the beans and get the properties on each bean. Is this possible?

    Example code:



    _________________________________________________________
    Do You Yahoo!?
    Get your free @yahoo.com address at http://mail.yahoo.com





------------------------------------------------------------------------------
  Do You Yahoo!?
  Yahoo! Mail Personal Address - Get email at your own domain with Yahoo! Mail.

Re: Is this possible with Struts?

Posted by David Winterfeldt <dw...@yahoo.com>.
This calls getLastName() on each object in the list.

<logic:iterate id="results" name="myList">
   <bean:write name="results" property="lastName"/><br>

</logic:iterate>


  Matt Raible <ma...@yahoo.com> wrote: I have an iteration of Beans and I want to list through the iteration,
extract the beans and get the properties on each bean. Is this possible?

Example code:



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com



---------------------------------
Do You Yahoo!?
Yahoo! Mail Personal Address - Get email at your own domain with Yahoo! Mail.