You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Caroline Jen <ji...@yahoo.com> on 2006/03/06 20:06:25 UTC

How To Use Existing Tags to Test and Write Out the Value of the Size of a Collection?

I have a Collection called 'remarks'.  I can use the
<logic:notEmpty> or <logic:empty> tags to test out if
the Collection has some elements in it or not.

1. Is there any tag I can use to test the size value
of that Collection to be zero or greater than zero?
Or I have to use the Java code in my JSP page?
 
2. Is there any tag I can use to output the 
 
   remarks.size();

   to the browser?

I simply think that it should not be too much Java
code in a JSP page.   


   


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: How To Use Existing Tags to Test and Write Out the Value of the Size of a Collection?

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
Theres also a <bean:size> in Struts

http://struts.apache.org/struts-doc-1.2.x/userGuide/struts-bean.html#size

Niall

----- Original Message ----- 
From: "Ed Griebel" <ed...@gmail.com>
Sent: Tuesday, March 07, 2006 2:48 PM


If you're using a JSP 2.0 container you can use fn:length(<expr>), see
http://www.onjava.com/pub/a/onjava/2003/11/05/jsp.html?page=last and
http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/fn/length.fn.html

If you're not using a JSP 2.0 container, you can use a taglib in the
Jakarta Taglibs sandbox, there's a size tag in the "unstandard"
taglib:
http://jakarta.apache.org/taglibs/sandbox/doc/unstandard-doc/intro.html.

I don't know how well supported the unstandard taglib is, but from
what I've found when looking at the source code for Unstandard is that
the methods are pretty basic and what I would write, so it saves me
writing my own tags.

-ed


On 3/6/06, Caroline Jen <ji...@yahoo.com> wrote:
> I have a Collection called 'remarks'.  I can use the
> <logic:notEmpty> or <logic:empty> tags to test out if
> the Collection has some elements in it or not.
>
> 1. Is there any tag I can use to test the size value
> of that Collection to be zero or greater than zero?
> Or I have to use the Java code in my JSP page?
>
> 2. Is there any tag I can use to output the
>
>    remarks.size();
>
>    to the browser?
>
> I simply think that it should not be too much Java
> code in a JSP page.



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


Re: How To Use Existing Tags to Test and Write Out the Value of the Size of a Collection?

Posted by Ed Griebel <ed...@gmail.com>.
If you're using a JSP 2.0 container you can use fn:length(<expr>), see
http://www.onjava.com/pub/a/onjava/2003/11/05/jsp.html?page=last and
http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/fn/length.fn.html

If you're not using a JSP 2.0 container, you can use a taglib in the
Jakarta Taglibs sandbox, there's a size tag in the "unstandard"
taglib: http://jakarta.apache.org/taglibs/sandbox/doc/unstandard-doc/intro.html.

I don't know how well supported the unstandard taglib is, but from
what I've found when looking at the source code for Unstandard is that
the methods are pretty basic and what I would write, so it saves me
writing my own tags.

-ed


On 3/6/06, Caroline Jen <ji...@yahoo.com> wrote:
> I have a Collection called 'remarks'.  I can use the
> <logic:notEmpty> or <logic:empty> tags to test out if
> the Collection has some elements in it or not.
>
> 1. Is there any tag I can use to test the size value
> of that Collection to be zero or greater than zero?
> Or I have to use the Java code in my JSP page?
>
> 2. Is there any tag I can use to output the
>
>    remarks.size();
>
>    to the browser?
>
> I simply think that it should not be too much Java
> code in a JSP page.
>
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


--
    "The greatest tyrannies are always perpetrated in the name of the
noblest causes." Thomas Paine
    "Those who would give up essential Liberty, to purchase a little
temporary Safety, deserve neither Liberty nor Safety" - Benjamin
Franklin

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