You have been redirected from an outdated version of the article. Below is the content available on this topic. To view the old article click here.

Condition

Flow Elements - Condition

Description

The Condition element evaluates given script to create a logic data result.

Parameters

Name Description
DataSource Accept another element’s DataTarget
ScriptSource Accepts another element’s DataTarget. Can be used to dynamically supply a script
Script Supplies script given for evaluation. Only used when ScriptSource is not connected
DataTarget Connects to a logic node DataSource or a Decision Condition
ExceptionHandler Connects to an ExceptionHandler’s HandledNodes socket

Search results for "Condition"

Decision

Name Description
Prev Accepts a connection from a Next socket
Condition Accepts a connection from a Result socket
Next If True Connects to a node’s Prev socket. Executed when condition is true
Next If False Connects to a node’s Prev socket. Executed when condition is false

Visibility

For HTML elements, Structr offers two additional ways to control the visibility during page rendering: showConditions and hideConditions. Both can contain a StructrScript or Javascript expression and - if they are filled - are evaluated before rendering. Depending on the return value of the script, the current element and its substructure will be displayed or hidden. Both fields are auto-script environments, i.e. the text in those fields is interpreted as a script without the need for the template expression markers ${...}.

Active Elements

The Active Elements flyout shows the list of active elements in the current page, i.e. all elements that have dynamic behaviour, like Repeaters, elements with show conditions or hide conditions, and the corresponding content elements that output dynamic content.

Conditional Flow

In the same way as data flows behave, whenever an element with connected conditional elements is evaluated, it will ask the connected logic element to evaluate itself. This in turn will recursively resolve all related conditionals.

Conditional Chaining

While conditional chaining is generally supported in our JavaScript environments, there are some niche cases that are not fully supported yet by the GraalVM. Specifically trying to apply conditional chaining on a ProxyObject that might have a function member and then trying to call said function leads to errors. The following example illustrates this issue.

Rendering Engine

When a user accesses the URL of a page with their browser, a process is started that runs through this tree structure from top to bottom and generates the HTML representation for each element. This process is called page rendering. Because of this sequential processing, it is possible to run through the same element more than once without additional effort (e.g. for each result of a database query) or to hide the content of specific elements depending on certain conditions (for access control). Together with the template and scripting language available in Structr, this creates an intuitive and extremely flexible rendering engine.

Comparison

Name Description
DataSources Accepts multiple DataTarget connections. Data that will be compared.
ValueSource Accepts DataTarget connection. Value that given data will be checked against.
Operation Defines boolean operator to be applied.
Result Connects to a logic node DataSource or a Decision Condition

Decision

The Decision element allows to split execution paths by deciding for a path depending on the given condition elements.

Condition

The Condition element evaluates given script to create a logic data result. The script must return a boolean value.

NotEmpty

Name Description
DataSources Accepts multiple DataTarget connections
Result Connects to a logic node DataSource or a Decision Condition

Condition

Name Description
DataSource Accept another element’s DataTarget
ScriptSource Accepts another element’s DataTarget. Can be used to dynamically supply a script
Script Supplies script given for evaluation. Only used when ScriptSource is not connected
DataTarget Connects to a logic node DataSource or a Decision Condition
ExceptionHandler Connects to an ExceptionHandler’s HandledNodes socket

And

Name Description
DataSources Accepts multiple logic node DataTarget connections
Result Connects to a logic node DataSource or a Decision Condition

Or

Name Description
DataSources Accepts multiple logic node DataTarget connections
Result Connects to a logic node DataSource or a Decision Condition

NotNull

Name Description
DataSources Accepts multiple DataTarget connections
Result Connects to a logic node DataSource or a Decision Condition

Not

Name Description
DataSources Accepts multiple logic node DataTarget connections
Result Connects to a logic node DataSource or a Decision Condition

Template Expressions

For complex processes within a template JavaScript can be used, because there are no directives or extra flow control elements in Structr templates unlike in Freemarker. Structr offers a very similar concept, show conditions, which are discussed in more detail in the “Visibility” paragraph below.

Main Properties

In the section “Main Properties” you can find the most important properties for the object you are editing. For a <div> element, those are the CSS class, the HTML id property and the CSS style attribute. Since divs are more likely to be dynamic elements, there are also input fields for Function Query, Data Key and Show / Hide Conditions.

StructrScript

StructrScript is the name of the internal scripting language that can be used in Content or Template nodes, Template Expressions, Show Conditions and HTML attributes. It is a simple interpreted functional scripting language that provides access to Structr’s functionality through a set of functions and keywords. StructrScript has no control structures, it is interpreted like a fully functional language, although some of the Built-In Functions have side effects.

Filter

Name Description
Prev Accepts another element’s Next socket
Next Connects to another element’s Prev socket
DataSource Accepts another element’s DataTarget
DataTarget Connects to another element’s DataSource
Condition Acceps connections from logic elements and uses connected logic to determine whether an element of the given collection gets filtered

Execution Flow

When a flow is called, execution will begin at it’s starting element. In case of no entry point being set or no elements being contained, the flow will simply return a null result. Otherwise the Flow Engine will evaluate the starting element and then proceed with the evaluation of the element connected to the initial element as next element. This continues until there is no more next element available, an error has been thrown or the evaluated element is a Return element, in which case the result of the element’s evaluation will be returned. Although this sums up the general execution flow of a Flow, there are notable exceptions to this in the form of specialized elements. For example a Decision element will branch into two execution paths and choose one based on the connected conditional elements. Likewise, a Loop element will enter a different execution path for each element and finally proceeds with the original next element.