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.

value

The value keyword returns the value passed to a FunctionProperty’s write function.

Search results for "value"

get_cache_value()

Retrieves the cached value for the given key.

Returns null if there is no stored value for the given key or if the stored value is expired.

get_cache_value(key)

has_cache_value()

Checks if a cached value exists for the given key. Returns false if there is no stored value for the given key or if the stored value is expired.

This function is especially useful if the result of a JavaScript function should be cached (see Example 2).

has_cache_value(key)

values()

Returns the list of property values for the given entity or object in the given property view. Or, when used with a single parameter that is a map / non-entity object type: returns all the values in the given object.

values(entity, propertyView)
values(object)

value

The value keyword returns the value passed to the write function of a FunctionProperty.

delete_cache_value()

Removes the cached value for the given key (if present).

delete_cache_value(key)

Changing Settings

There are several different types of configuration settings: string values, numerical values, boolean values and selection lists. For string settings and numerical settings, you can enter the desired value into the input field next to the title. For boolean settings, you can select “Enabled” or “Disabled”, and for selection lists, you can select one or more items by clicking on the desired value.

Periodic Task Scheduler

There are several supported notations for the fields:

Notation Meaning
* Execute for every possible value of the field.
x Execute at the given field value.
x-y  Execute for value x up to value y of the field.
*/x  Execute for every multiple of x in the field (in relation to the next bigger field).
Example Meaning
Hours = * Execute at every full hour.
Hours = 12 Execute at 12 o’clock.
Hours = 12-16 Execute at 12, 13, 14, 15, 16 o’clock.
Seconds = */15 In every minute, execute at 0, 15, 30, 45 seconds.
Seconds = */23 Special case: In every minute, execute at 0, 23, 46 seconds. If the unit is not evenly divisible by the given number the last interval is shorter than the others.

Passive Indexing

Passive indexing is the term for reading a dynamic value from a property (e.g. Function Property or Boolean Property) at application level, and writing it into the database at the end of each transaction, so the value is visible to Cypher. This is important for BooleanProperty, because its getProperty() method returns false instead of null even if there is no actual value in the database. Hence a Cypher query for this property with the value false would not return any results. Structr resolves this by reading all passively indexed properties of an entity, and writing them into the database at the end of a transaction.

Interfaces

application.host The listen address of the Structr HTTP server. If you set the listen address to 127.0.0.1, Structr will only be accessible for applications that run on the local host. This value essentially binds the HTTP server to the local loopback interface. The other option is 0.0.0.0 which makes Structr accessible from all networks.
application.http.port The HTTP port that Structr listens on. If you want to be able to access Structr under a simple http:// URL, you need to set this value to 80.
application.https.port The HTTPS port that Structr listens on. If you want to be able to access Structr under a simple https:// URL, you need to set this value to 443.
application.ssh.port The port that the SSHService listens on.
application.ftp.port The port that the FTPService listens on.
application.https.enabled If enabled, the internal HTTP server will be configured to allow HTTPS connections to the application.https.port.
application.keystore.path The path to a JKS keystore file that contains the certificate chain and private key for the SSL configuration needed for HTTPS. The keystore must be in PCK12 format.
application.keystore.password The password for the JKS keystore used in application.keystore.path.
application.baseurl.override Overrides baseUrl value that is originally assembled dynamically from the protocol, hostname and port of the server instance Structr is running on.

Outgoing Connection Timeouts

applications.httphelper.timeouts.connectionrequests Specifies a timeout for the request of an outgoing HTTP connection from the connection manager in seconds. A zero value is interpreted as infinite.
application.httphelper.timeouts.connect Specifies a timeout in seconds until an outgoing HTTP connection is established. A zero value is interpreted as infinite.
application.httphelper.timeouts.socket Specifies a timeout for the HTTP socket. If the time between two consecutive data packets is greater than the specified value, a timeout occurs. A zero value is interpreted as infinite.

CORS Settings

access.control.accepted.origins Accepts a comma-seperated list of allowed Origin values.
access.control.max.age Provides a value in seconds for the Access-Control-Max-Age header.
access.control.allow.method Accepts a comma-separated list of allowed HTTP request methods for the Access-Control-Allow-Methods header.
allow.control.allow.headers Accepts a comma-seperated list of allowed headers. Used for Access-Control-Allow-Headers header.
access.control.allow.credentials Accepts a value for the Access-Control-Allow-Credentials header.
access.control.expose.headers Accepts values for the Access-Control-Expose-Headers header.

Example Implementation

// get all required elements
const loginForm = document.getElementById('login-form');
const emailInput = document.getElementById('email');
const passwordInput = document.getElementById('password');
const loginButton = document.getElementById('login-button');

loginForm.addEventListener('submit', async (event) => {

event.preventDefault();

loginButton.disabled = true;

// get from values
const email = emailInput.value;
const password = passwordInput.value;

// login
const response = await fetch('/structr/rest/login', {
method: 'POST',
body: JSON.stringify({
eMail: email,
password: password
})
});

if (response.status === 202) {

let redirectUrl = response.headers.get('twoFactorLoginPage')
+ '?token=' + response.headers.get('token')
+ '&qrdata=' + (response.headers.get('qrdata') ?? '');

window.location.href = redirectUrl;

} else {

if (response.ok) {

loginButton.textContent = 'Login successful';
window.location.href = '/';

} else {

loginButton.disabled = false;
loginButton.textContent = 'Wrong username or password.';

window.setTimeout(function() {
loginButton.value = 'Login';
loginButton.disabled = false;
}, 2000);
}
}
});

Aggregate

Name Description
Prev Accepts another element’s Next socket
Next Connects to another element’s Prev socket
CurrentData Accepts another element’s DataSource. Given data is made available as currentData within the scripting context.
Data Accepts another element’s DataSource. Given data is start value of the aggregation and used to set it’s initial value.
DataTarget Connects to another element’s DataSource socket. Contains the aggregated data of the element.
ExceptionHandler If connected to an ExceptionHandler, exceptions thrown in the scripting context will be handled by the referenced handler.
Script context used to aggregate the data. Return value will be written to the element’s data.

Reset to default

If the value of a setting differs from the default, you will see a Reset icon next to the setting. If you click that button, the value will be reset to the default value immediately, i.e. without the need to click on the “Save” button.

Enum Property

The possible values of an Enum Property are defined in the schema/code area in the Format/Code field of the property. The values have to be provided as a comma-separated list.

Because Structr dynamically creates Java code from the format definition, the following limitations apply:

  • Enum-values must be simple alpha-numeric strings (i.e. no special characters, no spaces, etc)
  • Reserved words (like “boolean”, “final”, etc) are not allowed

This is not enforced by Structr but by Java itself as curating a comprehensive blacklist would not be feasible.

structr.conf

structr.conf is the main configuration file. It consists of key-value mappings which are managed automatically by the Configuration Tool. Since the Configuration Interface is the preferred way of editing configuration settings, the config file only stores the values that differ from the default value.

General

Please note that Structr only stores those values in the configuration file that differ from the default value. This means that you will not find an entry for most of the settings you see in the Configuration Tool, unless you changed its value.

Objects

A valid JSON object consists of quoted key-value mappings where the values can be strings, numbers, objects, arrays or null. Date values are represented by the ISO 8601 international date format string.

Example Implementation

<div id="qrimage-wrapper">
<img id="qrimage" style="margin-left: calc(50% - 100px);">
<div>To use two factor authentication, scan this QR code with an authenticator app on your smartphone.</div>

<div class="text-sm mt-6">
<div>
<b>Android: </b>
<a class="cursor-pointer hover:text-blue-400 text-blue-700" href="https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2&hl=en&gl=US">Google Authenticator</a> on Google Playstore
</div>
<div>
<b>Apple iOS: </b>
<a class="cursor-pointer hover:text-blue-400 text-blue-700" href="https://apps.apple.com/us/app/google-authenticator/id388497605">Google Authenticator</a> on App Store
</div>
</div>
</div>

<form action="#" id="twoFactorForm">
<input id="twoFactorToken" type="hidden" value="${request.token}">
<div class="my-6">
<label class="block text-sm font-medium leading-5 text-gray-700">Two Factor Code</label>
<input id="twoFactorCode" class="appearance-none block w-full px-3 py-2 bg-blue-100 border border-gray-300 rounded-md placeholder-gray-400 focus:outline-none focus:shadow-outline-blue focus:border-blue-300 transition duration-150 ease-in-out sm:text-sm sm:leading-5">
</div>
<button type="submit" id="login-button" class="w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-500 focus:outline-none focus:border-blue-700 focus:shadow-outline-indigo active:bg-blue-700 transition duration-150 ease-in-out">Login</button>
</form>

<script>
document.addEventListener('DOMContentLoaded', () => {

// get all required elements
const qrimageWrapper = document.getElementById('qrimage-wrapper');
const token = document.getElementById('twoFactorToken').value;
const codeInput = document.getElementById('twoFactorCode').value;
const loginButton = document.getElementById('login-button');

let qrdata = (new URLSearchParams(location.search)).get('qrdata');

if (!qrdata) {
// remove qr code placeholder if user is not shown qr code
qrimageWrapper.remove();
} else {
// transform url-safe qr code to regular base64 to display as image
qrimageWrapper.querySelector('#qrimage').src = 'data:image/png;base64, ' + qrdata.replaceAll('_', '/').replaceAll('-', '+');
}

document.getElementById('twoFactorForm').addEventListener('submit', async (event) => {

event.preventDefault();

loginButton.disabled = true;

const response = await fetch('/structr/rest/login', {
method: 'POST',
body: JSON.stringify({
twoFactorToken: token,
twoFactorCode: codeInput
})
});

if (response.ok) {

loginButton.textContent = 'Login successful';
window.location.href = '/';

} else {

let buttonText = 'Login failed - is device time correct?';

let reason = response.headers.get('reason');

if (reason === 'wrongTwoFactorCode') {
buttonText = 'Two Factor Code is not correct';
}

loginButton.disabled = false;
loginButton.textContent = buttonText;

window.setTimeout(function() {
loginButton.textContent = 'Login';
loginButton.disabled = false;
}, 2000);
}
});
});
</script>

file-import

file-import <source> <target> <mode> <existing> <index>  -  Import files directly from a server directoy.
<source> - Path to a directory on the server.
<target> - Target path in Structr's virtual file system.
<mode> - Whether to copy or move the files into Structr's files directory. Possible values: copy (default), move
<existing> - How to handle files already existing with the same path in Structr. Possible values: skip (default), overwrite, rename
<index> - Whether new files should be fulltext-indexed after import. Possible values: true (default), false