I think it would be. We had the situation where we had two lists that were being displayed using a single HTML table, with the first two columns being for list one, and the last two columns being for list two. Each row contains one list item. When the lists were of unequal size, empty cells would be left.
For this scenario, there was no way around using the size attribute. No matter what, we needed access to the size of the lists to determine which one was larger, and when we had gone past the size of one of the lists in our iteration. We got around the limitation by creating a JavaBeans compliant CollectionBean, which was a wrapper around a Collection. It provided getSize() and getCollection() methods that could be used in EL. -tb -----Original Message----- From: Shawn Bayern [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 28, 2002 9:04 PM To: Tag Libraries Users List Subject: Re: Size of a collection? 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]> *************************************************************************************** WARNING: All e-mail sent to and from this address will be received or otherwise recorded by the A.G. Edwards corporate e-mail system and is subject to archival, monitoring or review by, and/or disclosure to, someone other than the recipient. ***************************************************************************************
