Menu

setBooleanParser

Creates a parser that can make Boolean values out of Strings.

Parsers can be used in the logic with the set command, and in document content with the content logic attribute.

Attributes

name

Required
Value type
EL-evaluated
Yes String Yes
Defines a name for the created parser. Other commands can choose to use this parser by referring to it by this name.
trueString

Required
Value type
EL-evaluated
Yes String Yes
Defines the String that this parser will parse into a Boolean value of true. Any other String will then be parsed into a Boolean value of false.

Examples

Should your logic need to handle values that seem Booleans in nature, but are Strings instead, a Boolean parser can help out. You could have values such as "Open" and "Closed" for example - these could be parsed into a Boolean that tells if something is open or not with the following:

<setBooleanParser name="openParser" trueString="Open">

The set command could then be used to produce a Boolean out of that kind of String. Assuming the expression ${dataItem.open} resolves into either "Open" or "Closed", the following would work:

<set var="isOpen" value="${dataItem.open}" parser="openParser">

Comments

0 comments