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

Data type CardAvailable from FirstSpirit Version 5.2

Value range of the Card data type

Contents

Using the input component FS_CATALOG lists of sections or links can be entered and maintained. It returns a Catalog object. This contains Card objects. Card serves as connector between a template which is selected by the editor (according to the configuration of FS_CATALOG: a special, in the project existing section or link template), the form fields which are defined in the selected template and the values which are entered and stored in the form fields by the editor. For this reason, output of single values can be defined (see 1)), and output basing on the definition for the template set of the referenced (section or link) template (see 2)).

1) Output of single form fields on the basis of the template itsef

On the one hand, you can access the data stored in a single input component of FS_CATALOG.

For this purpose, use the method .getItem (in Bean syntax: .item). This returns an object of the type FormData. For achieving the values of an “inner” input component, you must specify the identifier of the input component, e.g.

<ul>
$CMS_FOR(var, st_catalog)$
<li>$CMS_VALUE(var.item.IDENTIFIER)$</li>
$CMS_END_FOR$
</ul>

Here, st_catalog is the variable name of the FS_CATALOG component, IDENTIFIER the variable name of the respective input component of the section or link template.

The objects will be returned language-dependent by default. For this reason, no language-dependent differentiation is needed.

With an iteration over the elements such as with $CMS_FOR(...)$ the system objects #card, #index and #fs_catalog are not available in the dependent section or link templates.

2) Output of the "Card" on the basis of the referenced template

On the other hand, you can use the section or link template which is deposited or selected by the editor for the output of the entries of FS_CATALOG. $CMS_VALUE(...)$ is used for this, for example

$CMS_VALUE(IDENTIFIER)$

Here, IDENTIFIER is the variable name of the FS_CATALOG component. I.e., the output of each element of the list depends on the definition of the template set of the selected section or link template.

You can use the system objects

  • #card (represents the entry (section or link) of an FS_CATALOG input component)
  • #index (determines the number of the currently rendered entry)
  • #fs_catalog (determines the number of entries of the FS_CATALOG input component)

in the dependent section or link template.

The data type Card can also be looked up in the API documentation:

de.espirit.firstspirit.client.access.editor.lists.Catalog$Card

Methods on Card objects

The table below lists all methods which can be invoked on objects of data type Card:

The object is generated by the following form objects:
FS_CATALOG
Method name Return type Brief description Available since
equals(Object) boolean
getClass Class Class of the invoking object
getId UUID Determining the UUID of an FS_CATALOG entry 5.2.181202
getItem FormData Provides the item referred to with this card 5.2.6
getTemplate Template Provides the template this card's item is based upon. 5.2.6
isCase(Object) boolean
isNull boolean Checks whether an expression is null (zero)
loadItem(FormData) void Loads the data from the given item into this card. 5.2.13
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

getId

The ID of the relevant FS_CATALOG entry ("Card") can be determined using the getId() method (in Bean syntax: .id). This ID can then be accessed during generation, for example. An ID of this type may appear as follows:

c84c8dae-512a-4142-9068-85208d4072fe

Syntax example:

<p>
$CMS_FOR(var,st_catalog)$
ID: $CMS_VALUE(var.getId())$
</p>

var is the identifier for the (list) object and st_catalog is the variable name of the FS_CATALOG component.

The text (content of the st_text input component) of a particular entry (in this case the FS_CATALOG entry with the ID 7644cfe2-b117-4ec7-bc94-bb8f255d1f59) can be output using the find(String) helper method with the following example syntax:

$CMS_VALUE(st_catalog.find("7644cfe2-b117-4ec7-bc94-bb8f255d1f59").get().item.st_text)$
Method name Return type Available since
getId UUID 5.2.181202

getItem

Provides the item referred to with this card.

For an example please see above.

Method name Return type Available since
getItem FormData 5.2.6

getTemplate

Provides the template this card's item is based upon.

Method name Return type Available since
getTemplate Template 5.2.6

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

loadItem(FormData)

Loads the data from the given item into this card.
Method name Return type Available since
loadItem(FormData) void 5.2.13

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 - 2022 Crownpeak Technology GmbH | All rights reserved. | FirstSpirit 2023.1 | Data privacy