On Wed, 27 Mar 2002, Biske, Todd wrote: > Is there any way in the EL to get the size of a collection? The > Collection API doesn't conform to the JavaBean syntax (size() instead > of getSize()).
Under the current EL spec, there's no way to do this with the EL alone. However, with JSTL's <c:forEach>, you could iterate over the collection and use the 'status' attribute to determine the size. To do this is a bit tricky, and is in many ways a terrible hack: it would perform awfully for large collections. I just mention it in case it's useful in your situation. Do you think that determining a size without actually iterating is a common use case for JSP/JSTL pages? If the EL ends up supporting functions, a size() function could easily be provided. This could also be done with custom (future JSTL?) actions oriented on the Collections API. Once I'm done with my upcoming book, I'd like to write such a Collections Taglib through Jakarta Taglibs. (I invite anyone to do it sooner, of course! I'm picturing tags like <collection:sort>, <collection:size>, <collection:reverse>, and so on. The goal would be to integrate cleanly with JSTL's <c:forEach>.) -- Shawn Bayern Author, "JSP Standard Tag Library" http://www.jstlbook.com (coming this summer from Manning Publications) -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
