You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mick Knutson <mi...@safeway.com> on 2005/07/06 19:36:15 UTC

How to access the first item in a Collection in a JSP?

    I have a Collection in my ActionForm, and want to access just the
first object in that Collection.
How can I do this?

--

Thanks
Mick Knutson
(925) 951-4126
HP Consulting Services
Safeway (Blackhawk Fastword Project)
J2EE Architect
---



"MMS <safeway.com>" made the following annotations.
------------------------------------------------------------------------------
Warning: 
All e-mail sent to this address will be received by the Safeway corporate e-mail system, and is subject to archival and review by someone other than the recipient.  This e-mail may contain information proprietary to Safeway and is intended only for the use of the intended recipient(s).  If the reader of this message is not the intended recipient(s), you are notified that you have received this message in error and that any review, dissemination, distribution or copying of this message is strictly prohibited.  If you have received this message in error, please notify the sender immediately. 
  
==============================================================================


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


Re: How to access the first item in a Collection in a JSP?

Posted by Mick Knutson <mi...@safeway.com>.
Worked. Thanks..

Zarar Siddiqi wrote:

> > Wel, I catually have something like form.cards[0].cardNumber, but it is
> > also not an array. It is a collection.
>
> Doesn't matter, it works for both as long as you got a getCardNumber() in
> there.
>
> > Wendy Smoak wrote:
> >
> >> From: "Mick Knutson" <mi...@safeway.com>
> >>
> >> > I have a Collection in my ActionForm, and want to access just the
> >> > first object in that Collection.
> >>
> >> How about...
> >>    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
> >>    <c:out value="${form.property[0]}"/>
> >>
> >> --
> >> Wendy Smoak
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >
> > --
> >
> > Thanks
> > Mick Knutson
> > (925) 951-4126
> > HP Consulting Services
> > Safeway (Blackhawk Fastword Project)
> > J2EE Architect
> > ---
> >
> >
> >
> > "MMS <safeway.com>" made the following annotations.
> > ------------------------------------------------------------------------------
> > Warning:
> > All e-mail sent to this address will be received by the Safeway corporate
> > e-mail system, and is subject to archival and review by someone other than
> > the recipient.  This e-mail may contain information proprietary to Safeway
> > and is intended only for the use of the intended recipient(s).  If the
> > reader of this message is not the intended recipient(s), you are notified
> > that you have received this message in error and that any review,
> > dissemination, distribution or copying of this message is strictly
> > prohibited.  If you have received this message in error, please notify the
> > sender immediately.
> >
> > ==============================================================================
> >
> >
> > ---------------------------------------------------------------------
> > 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

--

Thanks
Mick Knutson
(925) 951-4126
HP Consulting Services
Safeway (Blackhawk Fastword Project)
J2EE Architect
---



"MMS <safeway.com>" made the following annotations.
------------------------------------------------------------------------------
Warning: 
All e-mail sent to this address will be received by the Safeway corporate e-mail system, and is subject to archival and review by someone other than the recipient.  This e-mail may contain information proprietary to Safeway and is intended only for the use of the intended recipient(s).  If the reader of this message is not the intended recipient(s), you are notified that you have received this message in error and that any review, dissemination, distribution or copying of this message is strictly prohibited.  If you have received this message in error, please notify the sender immediately. 
  
==============================================================================


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


Re: How to access the first item in a Collection in a JSP?

Posted by Zarar Siddiqi <za...@utoronto.ca>.
> Wel, I catually have something like form.cards[0].cardNumber, but it is
> also not an array. It is a collection.

Doesn't matter, it works for both as long as you got a getCardNumber() in 
there.


> Wendy Smoak wrote:
>
>> From: "Mick Knutson" <mi...@safeway.com>
>>
>> > I have a Collection in my ActionForm, and want to access just the
>> > first object in that Collection.
>>
>> How about...
>>    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
>>    <c:out value="${form.property[0]}"/>
>>
>> --
>> Wendy Smoak
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>
> --
>
> Thanks
> Mick Knutson
> (925) 951-4126
> HP Consulting Services
> Safeway (Blackhawk Fastword Project)
> J2EE Architect
> ---
>
>
>
> "MMS <safeway.com>" made the following annotations.
> ------------------------------------------------------------------------------
> Warning:
> All e-mail sent to this address will be received by the Safeway corporate 
> e-mail system, and is subject to archival and review by someone other than 
> the recipient.  This e-mail may contain information proprietary to Safeway 
> and is intended only for the use of the intended recipient(s).  If the 
> reader of this message is not the intended recipient(s), you are notified 
> that you have received this message in error and that any review, 
> dissemination, distribution or copying of this message is strictly 
> prohibited.  If you have received this message in error, please notify the 
> sender immediately.
>
> ==============================================================================
>
>
> ---------------------------------------------------------------------
> 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: How to access the first item in a Collection in a JSP?

Posted by Martin Gainty <mg...@hotmail.com>.
Mick-
Or you could use map entry..

<c:forEach var="entry" items="${QUERYRESULT["FormName"]}">
<c:out value="${entry.key}"/> -
<c:forEach var="eo" items='${entry.value}'>
${eo.name.value}
</c:forEach>
</c:forEach>

HTH,
Martin-
----- Original Message ----- 
From: "Mick Knutson" <mi...@safeway.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Wednesday, July 06, 2005 4:19 PM
Subject: Re: How to access the first item in a Collection in a JSP?


> Wel, I catually have something like form.cards[0].cardNumber, but it is
> also not an array. It is a collection.
>
> Wendy Smoak wrote:
>
>> From: "Mick Knutson" <mi...@safeway.com>
>>
>> > I have a Collection in my ActionForm, and want to access just the
>> > first object in that Collection.
>>
>> How about...
>>    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
>>    <c:out value="${form.property[0]}"/>
>>
>> --
>> Wendy Smoak
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>
> --
>
> Thanks
> Mick Knutson
> (925) 951-4126
> HP Consulting Services
> Safeway (Blackhawk Fastword Project)
> J2EE Architect
> ---
>
>
>
> "MMS <safeway.com>" made the following annotations.
> ------------------------------------------------------------------------------
> Warning:
> All e-mail sent to this address will be received by the Safeway corporate 
> e-mail system, and is subject to archival and review by someone other than 
> the recipient.  This e-mail may contain information proprietary to Safeway 
> and is intended only for the use of the intended recipient(s).  If the 
> reader of this message is not the intended recipient(s), you are notified 
> that you have received this message in error and that any review, 
> dissemination, distribution or copying of this message is strictly 
> prohibited.  If you have received this message in error, please notify the 
> sender immediately.
>
> ==============================================================================
>
>
> ---------------------------------------------------------------------
> 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: How to access the first item in a Collection in a JSP?

Posted by Mick Knutson <mi...@safeway.com>.
Wel, I catually have something like form.cards[0].cardNumber, but it is
also not an array. It is a collection.

Wendy Smoak wrote:

> From: "Mick Knutson" <mi...@safeway.com>
>
> > I have a Collection in my ActionForm, and want to access just the
> > first object in that Collection.
>
> How about...
>    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
>    <c:out value="${form.property[0]}"/>
>
> --
> Wendy Smoak
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org

--

Thanks
Mick Knutson
(925) 951-4126
HP Consulting Services
Safeway (Blackhawk Fastword Project)
J2EE Architect
---



"MMS <safeway.com>" made the following annotations.
------------------------------------------------------------------------------
Warning: 
All e-mail sent to this address will be received by the Safeway corporate e-mail system, and is subject to archival and review by someone other than the recipient.  This e-mail may contain information proprietary to Safeway and is intended only for the use of the intended recipient(s).  If the reader of this message is not the intended recipient(s), you are notified that you have received this message in error and that any review, dissemination, distribution or copying of this message is strictly prohibited.  If you have received this message in error, please notify the sender immediately. 
  
==============================================================================


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


Re: How to access the first item in a Collection in a JSP?

Posted by Wendy Smoak <ja...@wendysmoak.com>.
From: "Mick Knutson" <mi...@safeway.com>

> I have a Collection in my ActionForm, and want to access just the
> first object in that Collection.

How about... 
   <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
   <c:out value="${form.property[0]}"/>

-- 
Wendy Smoak

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