Orbeon Forms
Search…
Extension API

Availability

Since Orbeon Forms 2016.1.

Introduction

Form Builder exposes the following developer extension API:
    API to add a custom Form Settings tab
    API to add a custom Control Settings tab
Each extension is implemented with an XBL component. The component interacts with the enclosing dialog via events.

Setting up an XBL component

First, make sure you have chosen a prefix-to-namespace mapping for your components, as explained in Automatic inclusion of XBL bindings.
Below, we assume the following example mapping:
1
<property
2
as="xs:string"
3
name="oxf.xforms.xbl.mapping.acme"
4
value="http://www.acme.com/xbl"/>
Copied!
In practice, you would probably choose a prefix different from acme, and a namespace different from http://www.acme.com/xbl.
For more on XBL components, see XBL documentation.

Custom Form Settings tab

Setup

In order to add a custom Form Settings tab, the following property must be set to a non-blank value:
1
<property
2
as="xs:string"
3
name="oxf.fb.extension.form-settings"
4
value="acme:form-settings"/>
Copied!
Here, the value acme:form-settings refers to the XBL component implementing the custom tab:
    acme is the prefix you have mapped with the oxf.xforms.xbl.mapping.acme property above
    form-settings is the name you give your XBL component (it doesn't have to be form-settings)

The XBL component

You then create the file implementing the component under:
1
WEB-INF/resources/xbl/acme/form-settings/form-settings.xbl
Copied!
Here is a template for the new XBL component:
1
<xbl:xbl xmlns:xh="http://www.w3.org/1999/xhtml"
2
xmlns:xf="http://www.w3.org/2002/xforms"
3
xmlns:xs="http://www.w3.org/2001/XMLSchema"
4
xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
5
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
6
xmlns:xbl="http://www.w3.org/ns/xbl"
7
xmlns:xxbl="http://orbeon.org/oxf/xml/xbl"
8
9
xmlns:acme="http://www.acme.com/xbl">
10
11
<xbl:binding element="acme|form-settings" id="acme-form-settings">
12
<xbl:handlers>
13
<xbl:handler event="fb-initialize" phase="target">
14
15
<!-- Example: access the form instance root -->
16
<xf:var name="root" value="event('form-instance')"/>
17
18
<!-- Further initialization -->
19
20
</xbl:handler>
21
<xbl:handler event="fb-apply" phase="target">
22
23
<!-- Example: access the form instance root -->
24
<xf:var name="root" value="event('form-instance')"/>
25
26
<!-- Further code to save settings -->
27
28
</xbl:handler>
29
</xbl:handlers>
30
<!-- Local models -->
31
<xbl:implementation>
32
<xf:model>
33
34
<!-- Local instance -->
35
<xf:instance>
36
<some-local-instance/>
37
</xf:instance>
38
39
<!-- Further model content -->
40
41
</xf:model>
42
</xbl:implementation>
43
<!-- View template -->
44
<xbl:template>
45
<xh:div>
46
This will appear as the tab's content.
47
</xh:div>
48
</xbl:template>
49
</xbl:binding>
50
51
</xbl:xbl>
Copied!

Responding to events

Events dispatched

Form Builder dispatches events to the component, following a predefined lifecycle:
    fb-initialize is dispatched to initialize the tab when the dialog shows.
    fb-apply is dispatched to save the settings, if any, to the form definition.
Handlers for these events can access the form definition and read from / write to it. Component authors have to be very careful not damaging the form definition in the process.

Event parameters

fb-initialize and fb-apply both take the following parameters:
Parameter Name
Type
Value
form
element(xh:html)
root element of the form definition
form-instance
element(form)
root element of the form definition's form instance
form-metadata
element(metadata)
root element of the form definition's form metadata

Custom Control Settings tab

Setup

In order to add a custom Control Settings tab, the following property must be set to a non-blank value:
1
<property
2
as="xs:string"
3
name="oxf.fb.extension.control-settings"
4
value="acme:control-settings"/>
Copied!
Here, the value acme:control-settings refers to the XBL component implementing the custom tab:
    acme is the prefix you have mapped with the oxf.xforms.xbl.mapping.acme property above
    control-settings is the name you give your XBL component (it doesn't have to be control-settings)

The XBL component

You then create the file implementing the component under:
1
WEB-INF/resources/xbl/acme/control-settings/control-settings.xbl
Copied!
For instance, see control-settings.xbl, an example of custom Control Settings that lets form authors enter, for each control, a "question identifier", which value is stored in an attribute of the form data, on the element corresponding that corresponds to the current control.
For an example template, see above for acme:form-settings.

Responding to events

Events dispatched

Form Builder dispatches the following events to the component:
    fb-initialize is dispatched to initialize the tab when the dialog shows.
    fb-apply is dispatched to save the settings, if any, to the form definition.
Handlers for these events can access the form definition and read from / write to it. Component authors have to be very careful not damaging the form definition in the process.

Event parameters

fb-initialize and fb-apply both take the following parameters:
Parameter Name
Type
Value
form
element(xh:html)
root element of the form definition
form-instance
element(form)
root element of the form definition's form instance
form-metadata
element(metadata)
root element of the form definition's form metadata
data-holders
element()*
all data holders for the given control
In addition, fb-initialize takes the following parameters:
Parameter Name
Type
Value
original-control-id
xs:string
original control id, such as first-name-control
original-control-name
xs:string
original control name, such as first-name
In addition, fb-apply takes the following parameters:
Parameter Name
Type
Value
control-name
xs:string
new control name, such as first-name
Between fb-initialize and fb-apply, the control name (and id) might have been changed in the dialog by the user. The original-control-name and control-name parameters reflect that change when needed.
Last modified 9mo ago