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

Data type DatasetContainerAvailable from FirstSpirit Version 4.2

Value range of the data type DatasetContainer

FirstSpirit provides the data type DatasetContainer for the processing of values which represent structured data from the Content Store of FirstSpirit. The data type DatasetContainer represents a logical grouping of an entity (Entity data type) from a database and the relating table template of a FirstSpirit project.

For further information about the data type DatasetContainer see API documentation:

de.espirit.firstspirit.access.editor.value.DatasetContainer

Definition using the standard input components

Using the input component FS_DATASET a dataset is referenced from the Content Store. This input component returns the data type DatasetContainer by means of a $CMS_VALUE(...)$ instruction when accessing the stored value.

Creating DatasetContainer programmatically

If you want to create new DatasetContainer object, which contains a specific entity, programmatically, you can use the methods of the sub-object Factory. This new DatasetContainer can then be assigned as value to a FS_DATASET component.

The methods of the Factory object are specified in the API documentation: de.espirit.firstspirit.access.editor.value.DatasetContainer.Factory

For creating a DatasetContainer a new object of the type DatasetContainer.Factory must be instantiated first. By means of the methods create(...) of this object a data record or an entity, a table template and a project language can be used to create a new DatasetContainer object, configured with these elements. This object will then be assigned to the form of a FS_DATASET input component:

//!Beanshell

import de.espirit.firstspirit.access.store.Store;
import de.espirit.firstspirit.access.editor.value.DatasetContainer;
import de.espirit.firstspirit.access.editor.value.DatasetContainer.Factory;

// Setup
element = context.getElement();
userService = context.getUserService();
projectLanguage = context.getProject().getMasterLanguage();

// Obtain an entity from the Content Store
contentStoreRoot = userService.getStore(Store.Type.CONTENTSTORE);
dataSource = contentStoreRoot.getContent2ByName("myDataSourceUID");
tableTemplate = dataSource.getTemplate();
entity = dataSource.getData().get(0);

//
// Create new DatasetContainer object and assign it to an FS_DATASET input component
//

// Prepare the store element for editing and obtain form data
element.setLock(true, false);
formData = element.getFormData();
fsDatasetField = formData.get(projectLanguage, "fsDatasetComponentLabel");

// Use DatasetContainer.Factory to create a new DatasetContainer with the entity we've obtained earlier
DatasetContainer.Factory datasetContainerFactory = new DatasetContainer.Factory();
DatasetContainer newDatasetContainer = datasetContainerFactory.create(entity, tableTemplate, projectLanguage);

// Assign the new DatasetContainer to the FS_DATASET field and save the store element
fsDatasetField.set(newDatasetContainer);
element.setFormData(formData);
element.save();
element.setLock(false);
element.refresh();

Methods on DatasetContainer objects

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

The object is generated by the following form objects:
FS_DATASET
Method name Return type Brief description Available since
equals(Object) boolean
getClass Class Class of the invoking object
getDataset Dataset The stored dataset - may be null 4.2
getGid UUID The gid of the entity 5.0.307
getKey KeyValue The key value of the entity. 4.2
getLanguage Language The language for which this value is stored. 4.2
getTemplateUid String The uid of the template. 4.2
isCase(Object) boolean
isEmpty boolean Shortcut for getDataset() == null. 4.2
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

getDataset

The stored dataset - may be null
Method name Return type Available since
getDataset Dataset 4.2

getGid

The gid of the entity
Method name Return type Available since
getGid UUID 5.0.307

getKey

The key value of the entity.
Method name Return type Available since
getKey KeyValue 4.2

getLanguage

The language for which this value is stored.
Method name Return type Available since
getLanguage Language 4.2

getTemplateUid

The uid of the template.
Method name Return type Available since
getTemplateUid String 4.2

isCase(Object)

Method name Return type Available since
isCase(Object) boolean

isEmpty

Shortcut for getDataset() == null.
Method name Return type Available since
isEmpty boolean 4.2

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