Define Actions and Events in Fragments
When developing fragments, you use actions to define what should happen in your user interface and events to trigger those actions, much the same as in pages or flows. However, the scope of these actions and events is confined to the fragment itself, ensuring that the fragment is independent but unaware of its parent container's context.
This means a fragment cannot call action chains defined in the container (say, a page, layout, or even another fragment) that uses this fragment. It also cannot listen to events fired by the parent container, but it can fire custom events that "emit" to the parent container. See Pass Data Between a Fragment and Its Parent Container.
How you define actions events in a fragment is similar to those in other scopes, but not all events from other scopes are available in fragments. Here’s a list of event types and events supported within a fragment:
Type of Event | Description | How to Define |
---|---|---|
Component events | An event associated with a UI component in a page, including those in dynamic components. It’s possible to choose which event the component triggers, but available events will depend on the component. For example, an ojAction event is available to a button but not to an input text.
|
Start an Action Chain From a Component |
Variable events | An event specific to a variable that occurs when the value stored in the variable changes. The only available variable event is onValueChanged .
|
Start an Action Chain When a Variable Changes |
Lifecycle events | Predefined events that are automatically triggered during a fragment’s lifecycle:
|
Start an Action Chain From a Lifecycle Event |
Custom events | A user-defined event to start an action chain. Two types of custom events are supported in fragments:
|