8.3 Interaction Events


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 Events

This 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:

Rebuild

User interaction may have added or deleted nodes in the instance, and the result of this change may have affected the dependency relations that were computed earlier. This step rebuilds the dependency graph that records interdependencies among nodes in the instance data that are the result of model properties, such as relevant and calculate (see Chapter 5).

Recalculate

Using the updated dependency graph, the XForms processor recomputes the values and state of instance nodes affected by model properties. This results in recomputing the various dynamic model properties described in Chapter 5.

Revalidate

The updated instance is revalidated against the static and dynamic validity constraints defined by the model.

Refresh

The newly computed state information is communicated to the user interface that is bound to instances in the model. This update includes

  1. Reflecting new data values in the presentation of the user interface controls that bind to these values, and

  2. Reflecting the updated setting of model properties.

Event xforms-refresh communicates this updated state to the user interface by dispatching notification events detailed in Section 8.4.

8.3.2 Navigation Events

Navigation 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 Events

The 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 Reset

XForms 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.



XForms. XML Powered Web Forms with CD
XForms. XML Powered Web Forms with CD
ISBN: N/A
EAN: N/A
Year: 2003
Pages: 94

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net