collection:get
Will get an element from the Collection
specified. This tag will only work if the Collection is either a List
or a Map
.
Set
do not have a get method.
If your Collection is a Map
the key
and name/property
attributes must be the key value of the wanted element. But if the Collection is a List
the attributes must be the index of the wanted element.
This tag might return null, if the specified item does not exist or that null acctually are added in the Collection.
Syntax
<collection:get collection="..." id="..."? key="..."? name="..."? property="..."? type="..."?/>
Attributes
collection
, mandatoryThe collection to get element from. This must be either a
List
or aMap
.Set
do not have a get method.id
, no runtime expressionsIf the id is set the object will be made available as a scripting variable. If id is not specified the object fetched from the collection will be printed directly to the page.
type
Type of object that will be return from this tag. Either as a scripting variable or be written directly out. See the id-attribute.
key
Key of the object we will get from the
Map
or the index to get from theList
.name
Name to a bean to be used as key of the object we will get from the
Map
or the index to get from theList
.property
Specifies the name of the property to be used as key in the
Map
or theList
(on the bean specified by name).