You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Linus Nikander <li...@nikander.net> on 2004/07/31 14:39:25 UTC

Display collection size with jstl

How do I output the size of a collection whilst NOT in a loop ?

I've tried all the

<c:out value="collectionName.size" />
<c:out value="collectionName.length" />

variations I can think of but it doesn't seem to work.

Do I have to use a loop-structure to get at the size ? or do I have to bind
the collection to a page-variable before I can get the size ? Or is there a
syntax for getting it directly ?

The variable I'm trying to access is in session-scope

/Linus Nikander




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


Re: Display collection size with jstl

Posted by Bill Siggelkow <bi...@bellsouth.net>.
There is not a way to do it with JSTL 1.0 -- there is a way using the 
function tag lib in JSTL 1.1. If you are using Struts ;) use the 
<bean:size> tag to create a page-scoped variable which can then use.

Linus Nikander wrote:
> How do I output the size of a collection whilst NOT in a loop ?
> 
> I've tried all the
> 
> <c:out value="collectionName.size" />
> <c:out value="collectionName.length" />
> 
> variations I can think of but it doesn't seem to work.
> 
> Do I have to use a loop-structure to get at the size ? or do I have to bind
> the collection to a page-variable before I can get the size ? Or is there a
> syntax for getting it directly ?
> 
> The variable I'm trying to access is in session-scope
> 
> /Linus Nikander


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


Re: Display collection size with jstl

Posted by ron1 <ro...@gmx.net>.
use the tag bean:size
Cheers,
Ron


Linus Nikander wrote:
> How do I output the size of a collection whilst NOT in a loop ?
> 
> I've tried all the
> 
> <c:out value="collectionName.size" />
> <c:out value="collectionName.length" />
> 
> variations I can think of but it doesn't seem to work.
> 
> Do I have to use a loop-structure to get at the size ? or do I have to bind
> the collection to a page-variable before I can get the size ? Or is there a
> syntax for getting it directly ?
> 
> The variable I'm trying to access is in session-scope
> 
> /Linus Nikander


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


Re: Display collection size with jstl

Posted by Linus Nikander <li...@nikander.net>.
Hi Robert!

My news-server doesn't give me access to the JTSL list unfortunately. Since
many Struts developers use JSTL for presentation I thougt it'd be the proper
place to ask. Thank you for your answer anyhow.

//Linus


"Robert Taylor" <rt...@mulework.com> wrote in message
news:OCEBJBKGJIBAILNJEGCKIEEJIEAA.rtaylor@mulework.com...
> Linus, this question belongs on the JSTL mailing list.
> The answer can also be found in the JSLT 1.1 (mr) specification
> section 15.8.
>
> <c:out value="${fn:length(collectionName)}"/>
>
> robert
>
> > -----Original Message-----
> > From: news [mailto:news@sea.gmane.org]On Behalf Of Linus Nikander
> > Sent: Saturday, July 31, 2004 8:39 AM
> > To: user@struts.apache.org
> > Cc: displaytag-user@lists.sourceforge.net;
> > javagroups-users@lists.sourceforge.net
> > Subject: Display collection size with jstl
> >
> >
> > How do I output the size of a collection whilst NOT in a loop ?
> >
> > I've tried all the
> >
> > <c:out value="collectionName.size" />
> > <c:out value="collectionName.length" />
> >
> > variations I can think of but it doesn't seem to work.
> >
> > Do I have to use a loop-structure to get at the size ? or do I have to
bind
> > the collection to a page-variable before I can get the size ? Or is
there a
> > syntax for getting it directly ?
> >
> > The variable I'm trying to access is in session-scope
> >
> > /Linus Nikander
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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: Display collection size with jstl

Posted by Robert Taylor <rt...@mulework.com>.
Linus, this question belongs on the JSTL mailing list.
The answer can also be found in the JSLT 1.1 (mr) specification
section 15.8. 

<c:out value="${fn:length(collectionName)}"/>

robert

> -----Original Message-----
> From: news [mailto:news@sea.gmane.org]On Behalf Of Linus Nikander
> Sent: Saturday, July 31, 2004 8:39 AM
> To: user@struts.apache.org
> Cc: displaytag-user@lists.sourceforge.net;
> javagroups-users@lists.sourceforge.net
> Subject: Display collection size with jstl
> 
> 
> How do I output the size of a collection whilst NOT in a loop ?
> 
> I've tried all the
> 
> <c:out value="collectionName.size" />
> <c:out value="collectionName.length" />
> 
> variations I can think of but it doesn't seem to work.
> 
> Do I have to use a loop-structure to get at the size ? or do I have to bind
> the collection to a page-variable before I can get the size ? Or is there a
> syntax for getting it directly ?
> 
> The variable I'm trying to access is in session-scope
> 
> /Linus Nikander
> 
> 
> 
> 
> ---------------------------------------------------------------------
> 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