Java Reference
In-Depth Information
Table 8.8
<iterate> tag attributes
The property of the parameter containing the list.
property
(required)
This value is used to prepend to the tag's resulting body content. The
prepend
value will not be prepended (a) when the tag's resulting body con-
tent is empty; (b) if the tag is the first to produce body content and is
nested in a tag with the
removeFirstPrepend
attribute set to true; or (c) if
the tag is the first to produce body content following a
<dynamic>
tag with
a
prepend
attribute value that is not empty.
prepend
(optional)
open
(optional)
This value is used to prefix to the tag's resulting body content. The
open
value will not be prefixed if the tag's resulting body content is empty. The
open
value is prefixed before the
prepend
attribute's value is prefixed. For
example, if
prepend="OR "
and
open="("
, then the resulting combined
prefix would be
"OR ("
.
close
(optional)
The
close
value is used to append to the tag's resulting body content. The
append
value will not be appended if the tag's resulting body content is
empty.
This is the value used in between the rendering of the list values to the SQL
statement.
conjunction
(optional)
removeFirstPrepend
(optional)
The
removeFirstPrepend
attribute value defines whether the first nested
content-producing tag will have its
prepend
value removed.
Listing 8.7 shows how to use the iterate tag to build a more complex
WHERE
condi-
tion for our
SQL
statement.
Listing 8.7
<iterate> tag example
…
<select id="getProducts" parameterClass="Product"
resultClass="Product">
SELECT * FROM Products
<dynamic prepend="WHERE productType IN ">
<iterate property="productTypes"
open="(" close=")"
conjunction=",">
productType=#productType#
</iterate>
</dynamic>
</select>
…
In this example, we create a select statement, then iterate over a list of product
types to create a more complex filter for it.
















