NGCONSTANTS

Overview

The NGClient/Titanium Client constants provide essential configurations to control the behavior and appearance of web applications. These constants allow developers to customize aspects such as browser history, search mechanisms, branding, and session management, offering flexibility in creating user-centric experiences.

Browser history can be managed using the FORM_BASED_BROWSER_HISTORY constant, which determines whether the main form's name is appended to the URL in the browser's address bar. For enhanced search functionality, the VALUELIST_CONTAINS_SEARCH constant enables "contains" searches, offering broader query matching compared to default behaviors.

Branding is supported through properties like WINDOW_BRANDING_ICON_32 and WINDOW_BRANDING_ICON_192, which define icon images for windows or app shortcuts. The WINDOW_BRANDING_TITLE constant allows customization of the window's title text, providing a consistent and professional appearance when branding is enabled.

Session management is facilitated by the WINDOW_TIMEOUT constant, which specifies the duration for which a user session remains active after disconnection or navigation away from the app. This feature ensures continuity and flexibility for users returning within the configured timeframe.

Constants Summarized

Type
Name
Summary

By default the NGClient appends the name of the current main form to the url in the address bar of the browser using a fragment identifier (#.

the client property that can be set to always do a like search when filtering over valuelist on a typeahead like component.

Same as the WINDOW_BRANDING_ICON_32 client property just for images of size 192x192, usually used as shortcut icon for the web app.

Client property used to set the icon of the main window.

When use branding is enabled (see servoy.

When the user navigates to another page, closes the browser or is disconnected from the server, the client-session on the server will be kept for a limited time.

Constants Detailed

FORM_BASED_BROWSER_HISTORY

By default the NGClient appends the name of the current main form to the url in the address bar of the browser using a fragment identifier (#....)

By setting the FORM_BASED_BROWSER_HISTORY property to false, this is disabled The value can be true/false DEFAULT: true

Type String

Sample

application.putClientProperty(NGCONSTANTS.FORM_BASED_BROWSER_HISTORY, false);

the client property that can be set to always do a like search when filtering over valuelist on a typeahead like component. So a component that has a valuelist as a property and uses user input to search in that valuelist. By default it uses a like search with a % at the end (startsWith search on the fields of the valuelist). But this makes it a like %value% so a contains search.

This can be set on the element (element.putClientProperty() or on a application wide level (application.putClientProperty())

DEFAULT: false

Type String

Sample

elements.typeahead.putClientProperty(NGCONSTANTS.VALUELIST_CONTAINS_SEARCH, true);

WINDOW_BRANDING_ICON_192

Same as the WINDOW_BRANDING_ICON_32 client property just for images of size 192x192, usually used as shortcut icon for the web app.

Type String

WINDOW_BRANDING_ICON_32

Client property used to set the icon of the main window. This should be a PNG image of size 32x32, and it can be the file name that is stored under the web app root or it can be a base64 encoded image from the solution.

Type String

Sample

// set image from the web app root onSolutionOpen
application.putClientProperty(NGCONSTANTS.WINDOW_BRANDING_ICON_32, "favicon32x32.png");
// set base64 encoded image from solution onSolutionOpen
	var img = solutionModel.getMedia("favicon32x32.png")
	var imgAsBase64 = new Packages.org.apache.commons.codec.binary.Base64().encodeAsString(img.bytes);
	var imgHref = "data:image/png;base64," + imgAsBase64;
	application.putClientProperty(NGCONSTANTS.WINDOW_BRANDING_ICON_32, imgHref);

WINDOW_BRANDING_TITLE

When use branding is enabled (see servoy.branding setting in Servoy Admin Page / servoy.properties) this client property can be used to set the main window title text.

Type String

Sample

// set main window title onSolutionOpen
application.putClientProperty(NGCONSTANTS.WINDOW_BRANDING_TITLE, "My app title");

WINDOW_TIMEOUT

When the user navigates to another page, closes the browser or is disconnected from the server, the client-session on the server will be kept for a limited time. If the user returns within that time the client session is continued.

This time can be configured at the server (60 seconds by default) and can overridden for the current ng-client session using application.putClientProperty with NGCONSTANTS.WINDOW_TIMEOUT.

The value is specified in seconds.

Type String

Sample

// allow the user to return within 1 hour before the session is cleaned up
application.putClientProperty(NGCONSTANTS.WINDOW_TIMEOUT, 3600);

// get the current active timeout value, when not overriden via putClientProperty this will return the system value.
var timeout = application.getClientProperty(NGCONSTANTS.WINDOW_TIMEOUT);

// reset the value to the system value.
application.putClientProperty(NGCONSTANTS.WINDOW_TIMEOUT, null);

Last updated