setBoolean
A logic command that sets a variable with a Boolean value into the variable context.
Attributes
var | ||
---|---|---|
Required | Value type | EL-evaluated |
Yes | String | No |
Defines the name of the variable that will hold the Boolean. |
value | ||
---|---|---|
Required | Value type | EL-evaluated |
No | Any | Depends on the |
Defines the Boolean value this command is setting. If the resolved value is a Boolean, that Boolean is used as is. If the resolved value is of any other kind, it is converted into a String (unless it is a String already) and if its content is "true", the set Boolean is If undefined or the resolved value is |
expressionType | ||
---|---|---|
Required | Value type | EL-evaluated |
No | String | Yes |
Defines how the value expression of the
If this attribute is undefined, the value of "el" is used. |
Examples
The setBoolean
command provides an easy way to create Boolean values. While the set command can create Boolean values as well, this command is guaranteed to always produce a Boolean, regardless of how its value
is defined (or not defined at all). To have setBoolean
create a Boolean true
, all of the following would work:
<setBoolean var="itsTrue" value="${true}"><setBoolean var="itsTrue2" value="true"><setBoolean var="itsTrue3" value="${itsTrue}">
Creating a Boolean false
is generally easier, as if value
doesn't resolve into a Boolean true
or the String "true" - or is simply undefined - the resulting Boolean is false
.