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

DomElement data type

Value range of the DomElement data type

Several FirstSpirit input components store values structured in XML markup language. This is necessary as several contents can contain special markups, highlighting and information for specific parts.

In order to output or further process the contents stored in this way these input components return an object of the data type DomElement .

CMS_INPUT_DOM

For further information on the DomElement data type, see API documentation: de.espirit.firstspirit.access.editor.value.DomElement

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 DomElement :

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 DomElement objects

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

The object is generated by the following form objects:
CMS_INPUT_DOM
Method name Return type Brief description Available since
addChangeListener(ValueChangeListener) void Register a change listener. 4.0.17
adopt(DomElement) void Adopts all values from the given element. 4.0.17
diff(Element) Element Compute a difference between this element and the given one. 4.0
equals(Object) boolean
get Element Returns root element. 4.0.17
getClass Class Class of the invoking object
getRoot DefaultDomNode Returns root node (DOM) 4.2.15
isCase(Object) boolean
isEmpty boolean Checks whether an expression is empty 4.0.17
isNull boolean Checks whether an expression is null (zero)
normalize DomElement Outputting HTML-compliant lists and tables 5.1.300
parseHtml(String) void Sets the given html. 4.0.17
print void
removeChangeListener(ValueChangeListener) void Unregister a change listener. 4.0.17
renderToString String Output element as character string - is very calculation-intensive! 4.0.0
set(Element) void Sets root element. 4.0.17
set(String) void Sets the given xml. 4.0.17
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
toText(boolean) String Returns html (asHtml==true) or plain text (asHtml==false). 4.0.17
type String

addChangeListener(ValueChangeListener)

Register a change listener.
Method name Return type Available since
addChangeListener(ValueChangeListener) void 4.0.17

adopt(DomElement)

Adopts all values from the given element.
Method name Return type Available since
adopt(DomElement) void 4.0.17

diff(Element)

Compute a difference between this element and the given one.
Method name Return type Available since
diff(Element) Element 4.0

equals(Object)

Method name Return type Available since
equals(Object) boolean

get

Returns root element.
Method name Return type Available since
get Element 4.0.17

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

getRoot

Returns root node (DOM)
Method name Return type Available since
getRoot DefaultDomNode 4.2.15

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.

Method name Return type Available since
isEmpty boolean 4.0.17

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

normalize

In addition to inserting and formatting continuous text, the CMS_INPUT_DOM input component can also be used to generate and maintain lists and tables.

The content of a DOM editor is structured in paragraphs. A paragraph is displayed using a format template. This must be a "section format template" ("section formatting", see the Format templates page in the Basics section). In addition to the display in the editor, this format template also defines how the content that is identified in the DOM editor with this format template is output. In the event that

  • the editor has not selected a specific format template or
  • no section format template has been defined in the form using the FORMATS / TEMPLATE tags,

the "Default" format template should generally be used. By default, the content is output using <p> tags that enclose the content of a section in the DOM editor, for example:

<p>This is <b>formatted</b> text.</p>

However, other tags may be used depending on the format template that has been selected.

Inputs and outputs for lists and tables are also controlled using the selected section format template. If the "Default" format template is selected for a list or table, the output is also enclosed by <p> tags by default.

As a <p> element is a block element, it cannot contain any more block elements (lists, tables) in accordance with the HTML specification. However, from FirstSpirit version 5.1R3, the .normalize method can be used to configure the output of CMS_INPUT_DOM so that lists and tables are not enclosed by other tags that are generated by the section format template valid for the list or table.

Example:

$CMS_VALUE(pt_dom.normalize)$

pt_dom is the identifier for a CMS_INPUT_DOM input component.

If .normalize is not used, lists and tables in the HTML output may be enclosed by tags that come from the selected section format template, for example:

<p>Continuous text</p>
<p>Continuous text</p>
<p>
<ul>
<li>List element 1</li>
<li>List element 2</li>
<li>List element 3</li>
</ul>
</p>
<p>Continuous text</p>

If .normalize is used, lists and tables in the output are not enclosed by tags that come from the selected section format template, for example:

<p>Continuous text</p>
<p>Continuous text</p>
<ul>
<li>List element 1</li>
<li>List element 2</li>
<li>List element 3</li>
</ul>
<p>Continuous text</p>
Method name Return type Available since
normalize DomElement 5.1.300

parseHtml(String)

Sets the given html.
Method name Return type Available since
parseHtml(String) void 4.0.17

print

Method name Return type Available since
print void

removeChangeListener(ValueChangeListener)

Unregister a change listener.
Method name Return type Available since
removeChangeListener(ValueChangeListener) void 4.0.17

renderToString

The .renderToString() (in Bean syntax: .renderToString) method outputs a DOM element as a character string. This is necessary as the data is stored, e.g. in the input component DOM structured as XML. Then the XML of the input component is rendered the individual format templates are then applied.

Important The content of a DOM element can potentially be very large. Further, many format templates can be used in the rendering. Both are very calculation-intensive and therefore the renderToString method should only be used in exceptional cases.
Method name Return type Available since
renderToString String 4.0.0

set(Element)

Sets root element.
Method name Return type Available since
set(Element) void 4.0.17

set(String)

Sets the given xml.
Method name Return type Available since
set(String) void 4.0.17

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

toText(boolean)

Returns html (asHtml==true) or plain text (asHtml==false).
Method name Return type Available since
toText(boolean) String 4.0.17

type

Method name Return type Available since
type String

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