Skip to main content
Skip table of contents

toString

Creates a new variable holding a String that is created out of a specified value.

The kind of created String will vary depending on the value's type. A Number, for example, will simply become a String with the Number's numeric value in it, while a Map will be represented by a String resembling a JSON object with the Map's contents.

For certain value types this command has special handling as follows:

  • Collection - presented as a comma-separated list with a specific property representing each of the Collection's items.

  • File - if the MIME type is "HTML", "JSON" or "text/plain", the File is presented as a String with the File's content.

var

String

Defines the name of the variable holding the produced String.

value

Any

Defines the value from which a String is produced out of.

expr

String

Defines the EL-expression used to produce a String representation out of the value that the value attribute resolves into.

If the resolved value is a Collection, then this expression is evaluated for every item in the Collection. The item can appear in the expression represented by the variable name defined in itemName. The results of these evaluations then appear in the Collection's String form separated by commas.

If the resolved value is not a Collection, then this expression is evaluated with that value being the variable behind the name defined in itemName.

If this attribute is undefined, Collection items and other values are directly converted into Strings. Note that certain kinds of more complex values convert into descriptor Strings that are generally not very suitable for any use - with such values defining a proper expression for this attribute is highly recommended.

itemName

String

This attribute can be used to specify the name of the variable representing the item in the EL-expression specified in expr. If that attribute is undefined, this attribute does nothing.

If left undefined, the name of the item variable will be "x".

The toString command can produce a text representation of any value, but its primary feature is its ability to easily create text representations of Collections and text-based Files.

A Collection example:

CODE
<toString var="contactNames" value="${contacts}" itemName="contact" expr="${contact.Name}">
    

This would produce a String listing the names of all contacts in the Collection, separated with commas.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.