You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Deadman, Hal" <ha...@tallan.com> on 2001/02/13 01:25:27 UTC

how to determine size of collections using tags

Is there a way to determine the size of a collection that one might iterate
over using struts tags rather than a scriptlet? I often want to display one
thing if the collection is empty or I want to iterate over the collection.
The only thing I can think of involves adding a get method to the JavaBean
containing the collection that returns the collection size . That would let
me use the logic:equal tag to check the property. Is there a non-scriptlet
way to do this without adding a method to the JavaBean?

<logic:equal name="orderdetail" property="numOrderLineItems" value="0">
	// print message about lack of order line items 
</logic:equal>

<logic:greaterThan name="orderdetail" property="numOrderLineItems"
value="0">
   // start table
   <logic:iterate id="orderlineitem" name="orderdetail"
property="orderLineItems" type="com.blah.OrderLineItemJBean">
	// show each line item
   </logic:iterate>
</logic:equal>