Comments? Feedback?

This wiki does not yet support public comments (a limitation of Google Sites), so we encourage you to post your comments either:

On Twitter by responding to @orbeon.

On our community mailing list: subscribe sending an email to ops-users-subscribe@ow2.org (content of subject/body doesn't matter), you'll get a response with the email to use to send your message to the community mailing list.

Recent site activity

<script> and <action> actions for scripting

<script> or <action>?

[SINCE: 2011-04-07]

Two action names are available to run scripts:
  • <xxforms:script>:
    • this is a custom Orbeon Forms action
    • this never runs nested XForms actions
    • without a type attribute, the default is to run client-side JavaScript 
    • with a type attribute, this is able to run nested client-side JavaScript or server-side XPath scripts
  • <xforms:action type="...">:
    • this is a standard XForms action with an extension type attribute
    • without a type attribute, the behavior is standard XForms and runs nested XForms actions
    • with a type attribute, this is able to run nested client-side JavaScript or server-side XPath scripts
As of 2011-04, Orbeon favors the use of <xforms:action type="...">.

Client-side JavaScript

The <xxforms:script> action allows you to call client-side JavaScript as a result of XForms events:

<xforms:action ev:event="xforms-value-changed">
    <xforms:setvalue ref=".">test</xforms:setvalue>
    <xxforms:script>var v = 2; myValueChanged(v);</xxforms:script>
</xforms:action>

Scripts run with <xxforms:script> have access to the following JavaScript variables:
  • this: element observing the event causing <xxforms:script> to run
  • event:
    • event.target: returns the element which is the target of the event causing <xxforms:script> to run
NOTE: <xxforms:script> actions are currently always executed last in a sequence of XForms actions, even if they appear before other XForms actions.

[SINCE: 2011-04-07]

You can also run client-side JavaScript with <xforms:action> by setting the type attribute to javascript:

<xforms:action ev:event="xforms-value-changed">
    <xforms:setvalue ref=".">test</xforms:setvalue>
    <xforms:action type="javascript">var v = 2; myValueChanged(v);</xxforms:script>
</xforms:action>

Server-side XPath scripts

[SINCE: 2011-04-07]

Simple server-side scripts can be written in XPath. This is particularly useful when using extension functions that have side effects.

You specify an XPath script either with:

<xforms:action type="xpath">

or:

<xxforms:script type="xpath">

Example:

<xf:action type="xpath">
    xxf:set-session-attribute('foo', $total),
    xxf:set-session-attribute('bar', instance()/bar)
</xf:action>

When putting multiple XPath statements, separate them with a comma. This creates an XPath sequence, which is evaluated in order.

XPath scripts have access to the current XPath context, including the focus and in-scope variables.