tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Helios Alonso <halo...@atg.com.uy>
Subject Re: Rotating tables?
Date Wed, 04 Aug 2004 19:11:45 GMT
Solution 1:  two traversings

<tr>

<c:forEach items="..." var="x">
         <c:if test="${x.property=="MALE"}>
                 // display it
         </c:if>
</c:forEach>

</tr>

<tr>

<!-- the same for FEMALE -->
...

Solution 2: one traversing

<tr>

<c:forEach items="..." var="x">
         <c:if test="${x.property!=old}> <!-- the category changes -->
                 <c:if test="${old!=''}"> <!-- if there was a category 
before this -->
                 </tr>
                 </c>
                 <tr>
         </c:if>
         <!-- display x -->
</c:forEach>

</tr>

You could also put:
</tr><tr><td> <c:out value="${x.property}"/> </td>
and set old to an inexistent value before the loop, for forcing the opening.

If unclosed tr's is a problem try <c:out value="<tr>"/> and <c:out 
value="</tr>"/>

At 11:51 04/08/2004 -0700, you wrote:
>Actually, I have the table like that currently, which has a common attribute:
>
>To use our running example it looks like:
>
>MALE | JOHN | RED
>MALE | MARK | BLUE
>MALE | NIC | GREEN
>MALE | DAVID | BLUE
>FEMALE | SARA | ORANGE
>
>
>I want to display like:MALE: John (red) | Mark (blue) | Nic (Green) | 
>David (Blue)
>     FEMALE: Sara (orange)
>
>The color isn't an issue, its basically just grouping by a common 
>attribute and displaying it horizontally instead of vertically.
>
>- Nic
>
>Helios Alonso wrote:
>
>>I think he wants a table like this:
>>
>>+ John (in red)
>>+ Mark (in blue)
>>+ Nic (in green)
>>+ Helios (in red)
>>+ David (in blue)
>>....
>>
>>If you have an array of 3 colors named colors (I dont know but, maybe the 
>>set tag can build a mapping that works like an array...)
>>
>>Try this:
>><!-- initialization -->
>><c:set var="colorIndex" value="0"/>
>><!-- loop -->
>><tr>
>><td bgcolor="${colors[colorIndex++%3]}" >
>>
>>In the expression you're coding the round robin (increment and modulus 3) 
>>and the selection of the color based on the index.
>>
>>But, I didn't try it.  I hope the modulus is a valid construction in EL.
>>
>>At 11:05 04/08/2004 +0200, you wrote:
>>
>>>I'm not exactly sure what you mean with "rotate"?!
>>>
>>>Do you just have a collection that you want to iterate - with each each 
>>>entry corresponding to a "row" in the table? Or shall every row display 
>>>a different "column" of your table? It's hard to understand from your 
>>>examples..
>>>
>>>For displaying tabular data, you should check out the 
>>>displaytag-library: http://displaytag.sourceforge.net/  - it has 
>>>nothing  to with jstl, but gives you everything you will likely ever 
>>>need for displaying tables...
>>>
>>>cheers
>>>stf
>>>
>>>Nic Werner wrote:
>>>
>>>>Greetings,
>>>>    I have a table of data that I'd basically like to rotate, is this
>>>>possible/smart in JSTL?
>>>>Basically, I have an attribute with three colors, each one is a
>>>>different row in a table.
>>>>001 Blue data
>>>>001 Green data
>>>>002 Purple data
>>>>I want to have one row:001 | Blue Data | Green Data | Purple Data.
>>>>Any suggestions? Please help by pointing me elsewhere if you can....
>>>>- Nic
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>>
>>>
>>>--
>>>Stefan Frank
>>>iBioS - Intelligent BioInformatics Systems
>>>http://www.dkfz-heidelberg.de/ibios
>>>DKFZ - German Cancer Research Center
>>>Im Neuenheimer Feld 580
>>>69120 Heidelberg
>>>Tel.: +49 (0) 6221 42-3612
>>>Mail: s.frank@dkfz-heidelberg.de
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Mime
View raw message