It should also be relatively painless to use a composition/delegation approach.

public class CollectionBean {

  private Collection c;

  public int getSize() {
    return this.c.size();
  }

  public void setCollection(Collection c) {
    this.c = c;
  }

  public Collection getCollection() {
    return this.c;
  }
}

<jsp:useBean id="collBean" class="com.foo.CollectionBean"/>
<c:set target="${collBean}"
       property="collection"
       value="${requestScope.theCollection}"/>
<c:out value="${collBean.size}"/>

Or something along those lines. Of course, you could completely set up the 
collection bean prior to hitting the JSP as well.

Quoting David Graham <[EMAIL PROTECTED]>:

> I actually thought of a better idea which is getting into commons 
> collections territory but I'll post a quick description here.  I made a 
> JstlCollectionWrapper class that wraps any Collection object and implements
> 
> the Collection interface.  I added a getSize() method to this class.  The 
> business layer classes can return standard Java collections like ArrayList 
> and you can wrap them in this class when using them in JSTL.
> 
> A similar approach could be taken with the Map interface.  I wish they would
> 
> just add getSize to the standard classes :-(.
> 
> David

-- 
Kris Schneider <mailto:kris@;dotech.com>
D.O.Tech       <http://www.dotech.com/>

--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@;jakarta.apache.org>

Reply via email to