Once the XForms model and user interface have been initialized , the stage is set for user interaction. As the user interacts with the various controls and user interface constructs described in Chapter 3 and Chapter 4, the data model and user interface are kept synchronized by the XForms processor. 8.3.1 XForms Processing EventsThis model-view synchronization is achieved by implementing the rebuild , recalculate , revalidate , and refresh loop in response to user interaction events that change values in the data model. We encountered these operations as XForms actions in Section 7.2.9; these raise the corresponding XForms events shown in Table 7.1. All of these events are targeted at model to be affected. Following, we briefly outline the processing that takes place as these steps are performed. The goal of the XForms processing model is to maintain consistency between the user interface (the view) and the underlying data model. Providing new values via controls bound to the instance data results in these new values being stored in the instance. This triggers the XForms processing loop to actuate the following steps:
8.3.2 Navigation EventsNavigation events are dispatched in response to user actions that direct the browser displaying the XForms document to navigate among the various user interface controls. XForms navigation events are the mechanism by which the browser keeps the presentation synchronized with the XForms processing model. This synchronization is essential to ensure that user interface controls and aggregation constructs such as repeat and switch exhibit their expected behavior. Event xforms-focus corresponds to XForms action setfocus covered in Section 7.2.1; that action achieves its effect by dispatching event xforms-setfocus to the specified user interface control. The result is to give input focus to the specified control. This event is targeted at the control that should receive focus; it must be handled at the control; that is, this event cannot bubble . In addition, standard DOM2 notification events DOMFocusIn and DOMFocusOut can be used to advantage in attaching special behavior to XForms controls, for example, an accessibility aid might use these to track focus changes. Event xforms-focus and the associated setfocus action enable moving the focus to any user interface control. Events xforms- next and xforms-previous enable sequential navigation through the various controls in an XForms application. The navigation sequence defaults to document order and can be influenced by attribute navindex (see Section 3.2.4). XForms user agents can implement sequential navigation by dispatching event xforms-previous and xforms-next in response to the appropriate navigation keys, for example, tab and shift-tab . 8.3.3 Help EventsThe user can request help explicitly, for example, by pressing a help key or implicitly, for example, by hovering over a control in a visual interface or by not responding within a specified timeout when using a voice interface. Such user actions raise events xforms-help and xforms-hint respectively. These events are targeted at the current user interface control, that is, the control that has input focus. As described in Section 3.2.1, user interface controls capture the metadata needed to display help and tooltips via elements help and hint . As shown in Figure 7.2, these elements handle events xforms-help and xforms-hint . These events can bubble ; that is, a form control can delegate the handling of these events to one of its parents. Alternatively, a control may choose to handle these events by displaying the available help and to allow the event to bubble to the parent that might be able to provide additional contextual feedback. 8.3.4 Submit and ResetXForms events xforms-submit and xforms-reset correspond to actions send and reset , respectively. The former is targeted at element submission that is specified by action send ; the latter is targeted at the model being reset as specified by action reset . Both of these events may be canceled and are allowed to bubble . Event xforms-submit is handled by initiating submit processing as described in Section 3.8. Event xforms-reset results in the instance data within the specified model being reset to its initial state. |