Start page / Template development / Template syntax / Data types / Option

Option data type Available from FirstSpirit Version 4.0

Value range of the Option data type

In several set-valued input components, e.g. CHECKBOX, COMBOBOX, LIST and RADIOBUTTON, one or several entries can be selected.

An entry is represented in FirstSpirit by the data type Option .

If only one entry can be selected in the input component (e.g. COMBOBOX), an Option object is returned.

In the case of input components in which several entries can be selected (e.g. CHECKBOX), the input component returns a List of Option objects. Such a list can be output with the help of a $CMS_FOR(...)$ instruction.

Definition using the standard input components

Different input components can be defined in the form area of a page or section template. These form elements can then be used to insert the actual editorial contents into the page. The Standard input components supported by FirstSpirit return different data types.

The following standard input components return an object of data type Option :

Then, with the help of a $CMS_VALUE(...)$ instruction, methods can then be applied to this object:

$CMS_VALUE(IDENTIFIER.METHOD)$

Under IDENTIFIER, the resultname parameter, defined in the input component, must be specified.

Methods on Option objects

The table below lists all methods which can be invoked on objects of data type Option.

The object is generated by the following form objects:
CMS_INPUT_RADIOBUTTON
CMS_INPUT_COMBOBOX
CMS_INPUT_LIST
CMS_INPUT_CHECKBOX
Method name Return type Brief description Available since
compareTo(Object) int
equals(CharSequence) boolean
equals(Object) boolean
getClass Class Class of the invoking object
getKey String Get a textual key of this option. 4.0.17
getLabel(String) String Convenience method to get a label based on a language abbreviation. 4.0.30
getLabel(Language) String Try getting a label. 4.0.30
getValue Object Selected option 4.0.17
ignore(Language) boolean Indicates whether this Option should be ignored and therefore hidden in the gui for the provided language. 4.2.34
isCase(Object) boolean
isNull boolean Checks whether an expression is null (zero)
print void
putLabel(String, String) void Convenience method to put a label based on a language abbreviation. 4.0.30
putLabel(Language, String) void Set the label for the specified language. 4.0.30
set(String, Object) Object
toJSON String Convert to a JSON-compatible string representation including necessary quotes and escaping for immediate use. Handles Maps, Collections, Arrays, Numbers, Strings, Boolean, Date, and JsonElement. A date instance will be converted to an ISO-8601 formatted date string. Any object other than above will be converted using its 'toString()' value. 5.2.11
toString String
type String

compareTo(Object)

Method name Return type Available since
compareTo(Object) int

equals(CharSequence)

Method name Return type Available since
equals(CharSequence) boolean

equals(Object)

Method name Return type Available since
equals(Object) boolean

getClass

The .getClass() (in Bean syntax: .class) method returns the class of the invoking object (cf. java.lang.Class).

Invocation:

$CMS_VALUE(myString.class)$
$CMS_VALUE(myString.getClass())$

Output:

java.lang.String
Method name Return type Available since
getClass Class

getKey

Get a textual key of this option.
Method name Return type Available since
getKey String 4.0.17

getLabel(String)

Convenience method to get a label based on a language abbreviation.
Method name Return type Available since
getLabel(String) String 4.0.30

getLabel(Language)

Try getting a label.
Method name Return type Available since
getLabel(Language) String 4.0.30

getValue

The method getValue returns the selected option.

Method name Return type Available since
getValue Object 4.0.17

ignore(Language)

Indicates whether this Option should be ignored and therefore hidden in the gui for the provided language.
Method name Return type Available since
ignore(Language) boolean 4.2.34

isCase(Object)

Method name Return type Available since
isCase(Object) boolean

isNull

The .isNull() (in Bean syntax: .isNull) method checks whether an expression or object is null , e.g. storeElement.isNull(). In the case of objects with complex values or objects, the object decides when it is null. The data type DomElement for example always contains an empty document, thus it is never null. For this reason, checking an empty DOM editor input component by using the method .isNull() returns the value false, whereas checking the component with .isEmpty() would return the value true.

The method .isNull() returns a Boolean value as the check result. true is the check result if the expression or object is null and false if not.

Method name Return type Available since
isNull boolean

print

Method name Return type Available since
print void

putLabel(String, String)

Convenience method to put a label based on a language abbreviation.
Method name Return type Available since
putLabel(String, String) void 4.0.30

putLabel(Language, String)

Set the label for the specified language.
Method name Return type Available since
putLabel(Language, String) void 4.0.30

set(String, Object)

Method name Return type Available since
set(String, Object) Object

toJSON

Convert to a JSON-compatible string representation including necessary quotes and escaping for immediate use. Handles Maps, Collections, Arrays, Numbers, Strings, Boolean, Date, and JsonElement. A date instance will be converted to an ISO-8601 formatted date string. Any object other than above will be converted using its 'toString()' value.
Method name Return type Available since
toJSON String 5.2.11

toString

Method name Return type Available since
toString String

type

Method name Return type Available since
type String

© 2005 - 2024 Crownpeak Technology GmbH | All rights reserved. | FirstSpirit 2024.7 | Data privacy