• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

logic iterate

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>
 
Warning! Way too comfortable! Do not sit! Try reading this tiny ad instead:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic