Events and Interactions

Event System

Events connect user interactions in the browser to 4D functions on the server side.

Flow

  1. The user clicks a button or interacts with an element
  2. bweb.js sends the event via WebSocket to 4D
  3. 4D looks up the events configuration on the block
  4. Calls the function: ds.{className}.{functionName}()
  5. The function returns a WebFormController with response instructions
  6. The browser applies the response

Event Types

EventTrigger
onClickClick on a button
onSelectRowsRow selection in a listbox
onChangeField value change
onLoadBlock loading

Buttons and onClick

Configuring an onClick event in the block events:

{"onClick": [{"vt_ClassName": "MY_DATACLASS", "vt_FunctionName": "myFunction", "vo_Param": {"vt_BlocNameToSend": "UUID_WRAPPER_FIELDS"}}]}

vo_Param.vt_BlocNameToSend: UUID of the wrapper containing the fields whose values should be sent to the function.

renderFunction (Client-side)

JavaScript functions executed in the browser, without server call:

FunctionDescription
actionAccordingNumberLineEnables/disables a button based on listbox selection
showBlocShows a block
hideBlocHides a block
toggleBlocToggles block visibility

WebFormController (Server-side)

Object returned by 4D functions to control the response:

MethodDescription
reloadBlock("name")Refreshes a specific block
sendAlert("success", "msg")Displays a toast notification
showBloc("name") / hideBloc("name")Toggles block visibility
redirect("/url")Navigates to another page
addNewEntity()Prepares a new entity
save()Saves the current entity
removeEntity()Deletes the current entity

SearchEffect and Filters

Real-time search system integrated with listboxes. The search field triggers an event that filters the entity selection server-side.