Table of Contents | Prev | Next | Bottom |
Quick Table of Contents |
---|
9 XForms Actions 9.1 dispatch 9.2 refresh 9.3 recalculate 9.4 revalidate 9.5 setFocus 9.6 loadURI 9.7 setValue 9.8 submitInstance 9.9 resetInstance 9.10 setRepeatCursor 9.11 insert 9.12 delete 9.13 toggle 9.14 script 9.15 message 9.16 action |
All form controls defined in this specification have a set of common behaviors that encourage consistent authoring and look and feel for XForms-based applications. This consistency comes from attaching a common set of behaviors to the various form controls. In conjunction with the event binding mechanism provided by [XML Events], these handlers provide a flexible means for forms authors to specify event processing at appropriate points within the XForms user interface.
NOTE: This example is based on the XML Events specification [XML Events], which is proceeding independently from XForms, and thus might be slightly incorrect.
<xforms:button> <xforms:caption>Reset</xforms:caption> <xforms:resetInstance ev:event="xforms:activate"/> </xforms:button>
This example recreates the behavior of the HTML reset button, which this specification does not define as an independent form control.
For each built-in XForms action, this chapter lists the following:
Name
Description of behavior
XML Representation
Sample usage
All elements defined in this chapter explicitly allow global attributes from the XML Events namespace, and apply the processing defined in that specification in section 2.3 [XML Events].
This action explicitly dispatches an XForms Event to a specific element
identified by the target
attribute.
dispatch
>
<dispatch name = xsd:NMTOKEN target = xsd:IDREF bubbles = xsd:boolean : true cancelable = xsd:boolean : true />
name = xsd:NMTOKEN - required name of the event\ to dispatch.
target = xsd:IDREF - required reference to the event target.
bubbles = xsd:boolean : true - boolean indicating if this event bubbles—as defined in DOM2 events.
cancelable = xsd:boolean : true - boolean indicating if this event is cancelable—as defined in DOM2 events.
For events defined in the XForms specification, attributes
bubbles
and cancelable
have no effect, since these event
properties are defined in chapter 11 Processing Model.
This action dispatches an xforms:refresh
event.
refresh
>
<refresh/>
This action dispatches an xforms:recalculate
event.
recalculate
>
<recalculate/>
This action dispatches an xforms:revalidate
event.
revalidate
>
<revalidate/>
This action explicitly sets focus to the form control
referenced by the idref
attribute by dispatching an xforms:focus
event. Note that this event is implicitly invoked to implement XForms
accessibility features such as accessKey
.
setFocus
>
<setFocus idref = xsd:IDREF />
idref = xsd:IDREF - required reference to a form control
Setting focus to a repeating structure sets the focus to the member represented by the repeat cursor.
This action performs an XLink traversal.
loadURI
>
<loadURI (single node binding attributes) xlink:href = xsd:anyURI xlink:show = ("new" | "replace" | "embed" | "other" | "none") />
(single node binding attributes) - Selects the instance data node containing the URI.
xlink:href - optional URI to load.
xlink:show - optional link behavior specifier.
Either the single node binding attributes, pointing to a URI in the
instance data, or the attribute xlink:href
are required. If both are
present, the action has no effect.
Possible values for attribute xlink:show
have the following
processing for the document (or portion of a document) reached by traversing
the link:
The document is loaded into a new window (or other presentation context). Form processing in the original window continues.
The document is loaded into the current window. Form processing is interrupted, exactly as if the user had manually requested navigating to a new document.
The document is incorporated into the current window in an application-specific manner. Form processing continues.
The document is loaded in an application-specific manner. The application should look for other markup present in the link to determine the appropriate behavior.
The document is loaded in an application-specific manner. The application should not look for other markup present in the link to determine the appropriate behavior.
This action explicitly sets the value of the specified instance data node.
setValue
>
<setValue (single node binding attributes) value = XPath expression > <!-- literal value --> </setValue>
(single node binding attributes) - Selects the instance data node where the value is to be stored.
value = XPath expression - XPath expression to evaluate, with the result stored in the selected instance data node.
The element content of setValue
specifies the
literal value to set; this is an alternative to specifying a computed value via
attribute value
. The following two examples contrast these
approaches:
<setValue bind="put-here" value="a/b/c"/>
This causes the string value at a/b/c
in the instance data
to be placed on the single node selected by the bind element with
id="put-here"
.
<setValue bind="put-here">literal string</setValue>
This causes the value "literal string" to be placed on the single node selected
by the bind element with id="put-here"
.
If neither a value
attribute nor text content are present, the effect is to set the value of the selected node to the empty string ("").
This action explicitly initiates submit processing by
dispatching an xforms:submit
event.
submitInstance
>
<submitInstance submitInfo = xsd:IDREF />
id = xsd:ID - optional unique identifier.
submitInfo = xsd:IDREF - optional reference to asubmitInfo
element.
Note:
This XForms Action is a convenient way of expressing the following:
<dispatch target="mysubmitinfo" name="submitInstance"/>
This action explicitly initiates reset processing by
dispatching an xforms:reset
event.
resetInstance
>
<resetInstance model = xsd:IDREF />
model = xsd:IDREF - Selection of instance data for reset,defined at 8.12.3 Nodeset Binding Attributes
This action marks a specific item as current in a repeating sequence (within 10.3 Repeating Structures).
setRepeatCursor
>
<setRepeatCursor repeat = xsd:IDREF cursor = XPath expression that evaluates to number />
repeat = xsd:IDREF - required reference to a repeat
cursor = XPath expression that evaluates to number - required 1-based offset into the sequence.
This action copies nodes from the containing document into the instance data. Any nodes of type xsd:ID are not copied.
The rules for insert processing are as follows:
A new node-set is created by evaluating the node-set binding
attributes against the containing document child nodes of
instance
.
The last node of this node-set is deep copied into the instance
data, such that the inserted node appears immediately before or after
(depending on the value of attribute position
) the n
-th node in the node-set returned by evaluating the node-set binding
attributes against the instance data, where n
represents the number returned from node-set index evaluation,
below.
Note:
The XForms Action setValue
can be used in
conjunction with insert
to provide specific initial values for the
newly inserted nodes.
The rules for selecting a node-set index are as follows:
The return value of the XPath expression in attribute at
is processed according to the rules of the XPath function round()
. For example, the literal 1.5
becomes 2
, and the literal 'string'
becomes NaN
.
If the result is NaN
, the insert operation has no effect.
If the result is not a valid index for the node-set, it is clipped
to the either 1
or the size of the node-set, whichever is closer.
This action results in the insertion of model items to the XForms Model. These model items should be constructed by re-evaluating any necessary bindings and applying the XForms Constraints in scope for each node. When used with repeating structures 10.3 Repeating Structures, this causes the instantiation of the necessary user interface for populating a new entry in the underlying collection.
insert
>
<insert (node-set binding attributes) at = XPath expression position = "before" | "after" />
(nodeset binding attributes) - Selection of instance data nodes, defined at 8.12.3 Nodeset Binding Attributes
at - required XPath expression evaluated to determine insert location.
position - required selector if insert before/after behavior.
An example of using insert
with a repeating
structure is located at 10.3 Repeating Structures.
This action deletes nodes from the instance data.
The rules for delete processing are as follows:
A node-set is produced by evaluating the node-set binding attributes against the instance data.
The n
-th node is deleted from the instance data, where n
represents the number returned from node-set index evaluation, defined
in 9.11 insert.
This action results in the deletion of model items to the XForms Model. These model items should be deleted by re-evaluating any bindings that refer to the nodes being deleted. When used with repeating structures, this causes the destruction of the necessary user interface for populating the entry at the current cursor position in the underlying collection.
delete
>
<delete (node-set binding attributes) at = XPath expression />
(nodeset binding attributes) - Selection of instance data nodes, defined at 8.12.3 Nodeset Binding Attributes
at - XPath expression evaluated to determine insert location.
An example of using delete
with a repeating
structure is located at 10.3 Repeating Structures.
This action selects one possible choice from an exclusive
list e.g., within 10.2 Conditional Constructs For Dynamic User Interfaces, by dispatching an xforms:toggle
event.
toggle
>
<toggle case = xsd:IDREF />
case = xsd:IDREF - required reference to a case section inside the conditional construct
The toggle
action adjusts all selected
attributes on the affected case
s to reflect the new state.
This action executes script.
script
>
<script type = xsd:string > <!-- #CDATA --> </script>
type = xsd:string - required mime-type identifier of scripting language used
This action encapsulates a message to be displayed to the user.
message
>
<message (single node binding attributes) xlink:href = xsd:anyURI level = "ephemeral" | "modeless" | "modal" > <!-- mixed content --> </message>
(single node binding attributes) - optional attributes that point to the instance data for a string message.
xlink:href = xsd:anyURI - optional specifier of an external resource for the message.
level - required message level identifier.
The message specified can exist in instance data, in a remote
document, or as inline text. If multiple captions are specified in this
element, the order of preference is: ref
, xlink:href
,
inline.
A graphical browser might render an ephemeral message as follows:
A graphical browser might render a modeless message as follows:
A graphical browser might render a modal message as follows:
Table of Contents | Top |