Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Centralized client logic:

Most ui components allow users to run custom logic on certain events. (ex. on initialize, on value change, on before save, ...)
These customizable events are available directly from the repository, as attributes.
The attributes support simple JavaScript syntax:

...

  • self (deprecated) - the underlying dynObj of the triggering object
  • oSelf (deprecated) - the underlying controller of the triggering object
  • eventSource - the object on which the event is triggered
  • eventOrigin - the container from where the current screen was launched

The code implementation for centralized client logic is covered here: How to write centralized events

Decentralized client logic: (SWAT 22.13.0+)

As of SWAT 22.13.0, support for decentralized client logic has been introduced.
As seen in the example above, the functions need to be available in the global context to be able to reference them.
This means having to maintain that global context to avoid conflicts and having to reference the events by their full path.
Moreover, this also means that all the client logic is loaded in the main bundle.

...

Code Block
languagejs
titleEncapsulated lazy-loaded namespace
EventNamespace: '#'
EventAttribute: '$ #.function(eventSource);'

The code implementation for decentralized client logic is covered here: How to write decentralized events

To maintain backwards compatibility with the centralized client logic and to avoid redundant import checks, the decentralized client logic handling is activated only when an event namespace is assigned to the object master.
The event namespace needs to be assigned at object master level and, afterwards, it can be referenced within the master itself. (master-level, instance-level, menu-level).