When using XForms, you can reduce the form’s load and run time, as well as its memory usage, by nesting actions that are triggered by the same event. Furthermore, nesting actions ensures that they run in the order specified by the form designer.
When the form is opened, the parser traverses the entire form and creates event handlers for each action. If each action is listed individually, the parser needs to create more event handlers, which can increase the amount of time that it takes to load the form. Furthermore, when an event occurs, event handlers may trigger the activation of a number of implicit actions in addition to the action that the form designer explicitly requested. These implicit actions could include xforms:rebuild, xforms:recalculate, xforms:revalidate, and xforms:refresh. Therefore, nesting actions that are triggered by the same event reduces the number of implicit actions that are also executed.
To create a set of nested actions, they must be placed inside the <em>xforms:action</em> tag. This tag groups the actions together, so that all of the actions respond to the same trigger event. Once triggered, each action is processed in turn. The simplified structure for a set of nested actions would be:
The following code sample shows two nested actions that are activated off of the same xforms-value-changed event.
Exceptions to this practice
There are no exceptions to this practice.
Back to: Performance best practices