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

Data Type IndexAccessorAvailable from FirstSpirit Version 5.2

FS_INDEX input components store references to data objects (e.g. provided by external web services) using identifiers in String format. These identifiers are supplied by the data access plug-in associated with the input component in the form definition of a template. In order to access the actual data of an index entry, it is necessary to poll the data access plug-in's session object which resolves a String identifier to a matching data object.

In template set definitions of templates, accessing the value set of an FS_INDEX input component will return an object of type IndexAccessor which provides access to the stored String identifiers and additionally provides data objects matching the String identifiers, resolved by the data access plug-in associated with the input component.

Available from FirstSpirit Version 5.2R2 Starting with FirstSpirit 5.2R2, in snippet definitions, accessing an FS_INDEX input component will also return an object of type IndexAccessor.

Important This data type provides read-only access to the value set of an FS_INDEX input component. In other cases, such as access of an FS_INDEX component through a FormData object, an Index object will be returned, which provides means to manage the list of index entries and create new entries.
Method name Return type Brief description Available since
equals(Object) boolean
getClass Class Class of the invoking object
getIdentifiers List Returns String identifiers for references stored in an FS_INDEX input component 5.2.25
getSnippets List Provides snippets of entries in an FS_INDEX component 5.2.416
getValues List Provides data objects referenced by an FS_INDEX input component 5.2.25
isCase(Object) boolean
isEmpty boolean Checks whether an FS_INDEX input component does contain any entries 5.2.609
isNull boolean Checks whether an expression is null (zero)
print void
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

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

getIdentifiers

This method provides a list of String identifiers of references which are stored in an FS_INDEX input component.

Method name Return type Available since
getIdentifiers List 5.2.25

getSnippets

Using this method (in Bean syntax: .snippets), the snippets of the data access plug-in associated with the FS_INDEX component can be accessed, e.g.

FS_INDEX_VAR.snippets

The method returns a list. The required element in the list can be returned by indicating the position number (in square brackets; counting starts at 0).
To access the values of the snippets for the various entries in an FS_INDEX component, the following syntax can be used:

FS_INDEX_VAR.snippets[0].thumbnail
FS_INDEX_VAR.snippets[0].header
FS_INDEX_VAR.snippets[0].extract

In this case

  • thumbnail outputs the value of the Thumbnail field
  • header outputs the value of the Label field
  • extract outputs the value of the Extract field

The snippet definition of, in this case, the first entry in the associated data access plug-in.
See also Interface DataSnippet (Package de.espirit.firstspirit.agency).

The image is output (field Thumbnail view) using the following example syntax:

<img src="$CMS_REF(FS_INDEX_VAR.snippets[0].thumbnail.source)$"/>

Using $CMS_SWITCH(...)$ enables the output to be dependent on the type of image object, e.g.

$CMS_SWITCH(FS_INDEX_VAR.snippets[0].thumbnail.source)$ 
$CMS_CASE(class("de.espirit.firstspirit.access.store.mediastore.Media"))$
thumbnail: <img src="$CMS_REF(FS_INDEX_VAR.snippets[0].thumbnail.source)$"/>

$CMS_CASE(class("java.lang.String"))$
thumbnail: $CMS_VALUE(FS_INDEX_VAR.snippets[0].thumbnail.source)$
$CMS_END_SWITCH$

In this example, the output depends on whether the object is a media object (class de.espirit.firstspirit.access.store.mediastore.Media) or a string object (class java.lang.String).

Method name Return type Available since
getSnippets List 5.2.416

getValues

This method uses the data access plug-in associated with an FS_INDEX input component to resolve the String identifiers stored in the input component to data objects and provides a list of these data objects.

Method name Return type Available since
getValues List 5.2.25

isCase(Object)

Method name Return type Available since
isCase(Object) boolean

isEmpty

The .isEmpty() (in Bean syntax: .isEmpty) method checks whether an expression or object is empty, e.g. storeElement.isEmpty(). The result of the semantic check depends on the expression or object, e.g. a character string is empty if it does not contain any characters. In the case of objects with complex values or objects, the object decides when it is empty. 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 .isEmpty() returns a Boolean value as the check result. true is the check result if the expression or object is empty and false if not.

This method can be used for the data type IndexAccessor to check if the respective FS_INDEX input component contains entries or not:

  • If the input component contains at least one entry, the method returns false,
  • If the input component does not contain any entries, the method returns true.

Method name Return type Available since
isEmpty boolean 5.2.609

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

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.6 | Data privacy