You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Kathy Zhou <kz...@cmdservices.com> on 2004/05/27 22:54:40 UTC

presentation tag

How could I show 3 elements of a ArrayList per line on the page with 
<c:forEach> tag.

My code is:
HashMap ilist =......;
Its value is a ArrayList of javabeans having getter/setter methods.

<c:forEach var="vissue" items="${ilist}">
    c:out value="${vissue.key}"/><br>
	<c:forEach var="var" items="${vissue.value.pcode}">
	 	<c:out value="${var}"/><br>  <%--- need 3 var values per line --%>
	</c:forEach>	
 </c:forEach>

it shows me one pcode value per line on html page. But I want to show three 
pcodes per line. Since there is no index number I could use (I may be 
wrong) on the second <c:forEach> tag, how could I make it? Any suggestions?

Thank you.

Kathy






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


Re: presentation tag

Posted by Mark Lowe <ma...@boxstuff.com>.
This should sort you out.

<c:forEach var="vissue" items="${list}" varStatus="count">
<c:out value="${count.index}" />

</c:forEach>





On 27 May 2004, at 22:54, Kathy Zhou wrote:

>
> How could I show 3 elements of a ArrayList per line on the page with
> <c:forEach> tag.
>
> My code is:
> HashMap ilist =......;
> Its value is a ArrayList of javabeans having getter/setter methods.
>
> <c:forEach var="vissue" items="${ilist}">
>     c:out value="${vissue.key}"/><br>
> 	<c:forEach var="var" items="${vissue.value.pcode}">
> 	 	<c:out value="${var}"/><br>  <%--- need 3 var values per line --%>
> 	</c:forEach>	
>  </c:forEach>
>
> it shows me one pcode value per line on html page. But I want to show 
> three
> pcodes per line. Since there is no index number I could use (I may be
> wrong) on the second <c:forEach> tag, how could I make it? Any 
> suggestions?
>
> Thank you.
>
> Kathy
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>


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


Re: presentation tag- Thank you.

Posted by va...@bellsouth.net.
Mark and Joe,

Thank you very much for your info. I will try it out.
:)

Kathy
.
----- Original Message -----
From: "Joe Germuska" <Jo...@Germuska.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Thursday, May 27, 2004 5:15 PM
Subject: Re: <c:forEach> presentation tag


> At 4:54 PM -0400 5/27/04, Kathy Zhou wrote:
> >How could I show 3 elements of a ArrayList per line on the page with
> ><c:forEach> tag.
> >
> >My code is:
> >HashMap ilist =......;
> >Its value is a ArrayList of javabeans having getter/setter methods.
> >
> ><c:forEach var="vissue" items="${ilist}">
> >     c:out value="${vissue.key}"/><br>
> > <c:forEach var="var" items="${vissue.value.pcode}">
> > <c:out value="${var}"/><br>  <%--- need 3 var values
> >per line --%>
> > </c:forEach>
> >  </c:forEach>
> >
> >it shows me one pcode value per line on html page. But I want to show
three
> >pcodes per line. Since there is no index number I could use (I may be
> >wrong) on the second <c:forEach> tag, how could I make it? Any
suggestions?
>
> Use the "varStatus" attribute of c:forEach to specify the name under
> which the tag will define a "LoopTagStatus" bean.
>
> http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/c/forEach.html
>
http://java.sun.com/webservices/docs/1.3/api/javax/servlet/jsp/jstl/core/Loo
pTagStatus.html
>
> The LoopTagStatus bean has an index property.
>
> Joe
>
>
> --
> Joe Germuska
> Joe@Germuska.com
> http://blog.germuska.com
>        "Imagine if every Thursday your shoes exploded if you tied them
> the usual way.  This happens to us all the time with computers, and
> nobody thinks of complaining."
>              -- Jef Raskin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


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


Re: presentation tag

Posted by Joe Germuska <Jo...@Germuska.com>.
At 4:54 PM -0400 5/27/04, Kathy Zhou wrote:
>How could I show 3 elements of a ArrayList per line on the page with
><c:forEach> tag.
>
>My code is:
>HashMap ilist =......;
>Its value is a ArrayList of javabeans having getter/setter methods.
>
><c:forEach var="vissue" items="${ilist}">
>     c:out value="${vissue.key}"/><br>
>	<c:forEach var="var" items="${vissue.value.pcode}">
>		<c:out value="${var}"/><br>  <%--- need 3 var values 
>per line --%>
>	</c:forEach>
>  </c:forEach>
>
>it shows me one pcode value per line on html page. But I want to show three
>pcodes per line. Since there is no index number I could use (I may be
>wrong) on the second <c:forEach> tag, how could I make it? Any suggestions?

Use the "varStatus" attribute of c:forEach to specify the name under 
which the tag will define a "LoopTagStatus" bean.

http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/c/forEach.html
http://java.sun.com/webservices/docs/1.3/api/javax/servlet/jsp/jstl/core/LoopTagStatus.html

The LoopTagStatus bean has an index property.

Joe


-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
       "Imagine if every Thursday your shoes exploded if you tied them 
the usual way.  This happens to us all the time with computers, and 
nobody thinks of complaining."
             -- Jef Raskin

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