| < Day Day Up > |
|
The <bean:size /> tag is used to retrieve the number of elements contained in a reference to an array, collection, or map. The results of the <bean:size /> tag's evaluation is a scripting variable of type java.lang.Integer that contains the number of elements in that collection. You can specify the collection as a runtime expression, as a bean, or as a property of the bean named by the bean attribute. The <bean:size /> tag has no body and supports five attributes, as shown in Table 20.9.
Attribute | Description |
---|---|
id | Contains the scripting variable used to store the result of the evaluation. (Required) |
collection | Identifies the runtime expression that evaluates to an array, a collection, or a map. (Optional) |
name | Identifies the bean that contains the collection that will be counted. If the property attribute is specified, then the collection is assumed to be a data member of the bean; otherwise, the bean itself is assumed to be a collection. (Optional) |
property | Specifies the name of the property to be accessed on the bean identified by the name attribute whose getter method will return the collection to be counted. (Optional) |
scope | Identifies the scope of the bean specified by the name attribute. If the scope attribute is not specified, then the tag will search for the bean in the scopes, in the order of page, request, session, and application. (Optional) |
An example of using the <bean:size /> tag is shown here:
<bean:size name="users" />
In this example, we are counting the collection users and storing the results in the scripting variable count.
| < Day Day Up > |
|