addItem
Adds an item to a Collection. This new item will become the last item of the Collection.
Parent commands
setCollection
Optional. If placed as a child ofsetCollection
, thecollection
attribute may be left undefined to have the parent command's new Collection receive the item.
Attributes
value | ||
---|---|---|
Required | Value type | EL-evaluated |
Yes | Any | Yes |
The resolved value of this attribute is the new item for the Collection. |
collection | ||
---|---|---|
Required | Value type | EL-evaluated |
No | Collection | Yes |
Defines the Collection into which the new item is added. If this attribute is undefined and this command is a child of |
Examples
Using addItem
as a child of setCollection
causes the item to be added into the newly created Collection. Use this way to initialize fresh Collections with content.
<setCollection var="items"><addItem value="${item}">
If adding an item to an already existing Collection, the collection
attribute needs to be defined.
<setCollection var="items">...<addItem value="${item}" collection="${items}">