wood burning stoves 2.0*
The moose likes Struts and the fly likes logic iterate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "logic iterate" Watch "logic iterate" New topic
Author

logic iterate

Nicolas Flammel
Ranch Hand

Joined: May 05, 2004
Posts: 32
I have a logic iterate tag that lists the rows in the table form from a collection.
Is it possible to have alternate row colors within the iterate tag? How?
Markus Jura
Greenhorn

Joined: Jun 08, 2004
Posts: 7
yes, it is.
i have hear an very simple example. so you can realize two different colors and for each row the color switched:

code:
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>

<% String[] myCollection = {"entry1", "entry2", "entry3", "entry4", "entry5"}; %>

<table border="0" cellpadding="5" cellspacing="0">
<% String bgColor="#999999"; %>

<logic:iterate id="entry" indexId="rowIndex" collection="<%=myCollection%>" type="java.lang.String">
<tr bgcolor="<%=bgColor%>">
<td>Col 1</td>
<td>Col 2</td>
<td>Col 3</td>
</tr>
<% bgColor = (rowIndex.intValue() % 2 == 0) ? "#FFFFFF" : "#999999"; %>
</logic:iterate>
</table>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: logic iterate
 
Similar Threads
how to access hash-map in JSP using struts tags
Pass parameter dynamically in Javascript in html:select
I need help, with logic:iterate in HashMap
how to print values of a hashmap using logic:iterate
logic iterate tag