The Smart Device Applications generated by Smart Devices Generator include two types of events: Client Events and Server Events.
- Which is the triggering order for events in Smart Devices?
- Which events are executed on my Device (Client)?
- Which events are executed on the Server?
- What can I do in a Server event?
- What can I do in a Client event?
Here we will examine how this is managed, and the limitations and features we need to bear in mind for developing better Smart Device Applications.
You should already be familiar with System events (executed on Server) if you have some experience with Web or Windows Development with GeneXus. They are the Start, Refresh and Load Events.
Client events include the User events created by developers (there can be as many as desired), the Control events related to controls on the form and ClientStart event
Regardless of the event type we refer to, we want/need to know where the event is executed, because depending on that, the resources we may use will vary, and so will the applicable restrictions. There are also some differences relative to syntax issues that we should consider.
In these events (Start, Refresh, and Load) we can execute all the commands accepted by GeneXus.
- The Start event is executed the first time that a Panel for Smart Devices object or WWSD node is opened on a device. It will not be executed again unless we exit the panel or node and open it again.
- After the Start event, the Refresh event is executed. Normally, the Refresh event is executed only once after the Start event. Under certain circunstances the Refresh event may be executed more than once, whereas the Start event will execute only once. Moreover, as the navigation of the fixed part of the form and the grid are separated, each will have (if attributes) its own Base Table. So, the Refresh event accesses the fixed-part base table (if any).
- The Load event is the last of the system events executed and it is only executed when there is a grid on the layout. If the Grid has a Base Table, the Load event is executed as many times as registers exist in the base table (and if it is based on variables it will be executed once. If the grid is based on an SDT variable, the Load event will not be executed).
- When Refresh event is invoked, it will execute both the Refresh and the Load events.
- If both the fixed-part and the grid have base table, and if GeneXus finds a 1 to N relationship between them, the records of the Load will be the related ones. Otherwise, loads will be unrelated (there will be two independent navigations, one for the Refresh and another one for the Load).
- Remember that there is no possible scenario for a Refresh event to be executed unless the panel is activated (openend), or unless the Refresh event is invoked (through the Refresh command).
What happens behind the scene? Refer to Server-side Events in Smart Devices.
And what if it is a Detail with many Sections? Refer to Event Triggering Order in Smart Devices
Client events are the application's programmatic response to user interaction. These forms of interaction are called Smart Devices Actions and can be seen as buttons on the screen, as well as in images, or other controls that will execute the event associated with the action when tapped, long tapped, etc.
There are two main types of client events: user and control events. Both are associated with controls.
Client events enable developers to add behavior and logic to the application by mixing the execution between the client and server sides. As mentioned, Start, Refresh and Load are server events executed completely on server, meaning that they cannot use any of the device's resources. In client events we can combine the power of the server and the resources of our device.
What happens when user triggers an action (client event)? The associated code is executed on client side (on the device), unless a roundtrip to the server is required (for example, when a procedure must be invoked). In any case, system events are not executed unless they are explicitly required through the Refresh command.
So what can we do in a user event? Refer to Client-side Events in Smart Devices
Work With for Smart Devices – Behavior through Events
Events in Smart Devices