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:
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:
Here, the value acme:form-settings
refers to the XBL component implementing the custom tab:
acme
is the prefix you have mapped with theoxf.xforms.xbl.mapping.acme
property aboveform-settings
is the name you give your XBL component (it doesn't have to beform-settings
)
The XBL component
You then create the file implementing the component under:
Here is a template for the new XBL component:
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 |
|
| root element of the form definition |
|
| root element of the form definition's form instance |
|
| 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:
Here, the value acme:control-settings
refers to the XBL component implementing the custom tab:
acme
is the prefix you have mapped with theoxf.xforms.xbl.mapping.acme
property abovecontrol-settings
is the name you give your XBL component (it doesn't have to becontrol-settings
)
The XBL component
You then create the file implementing the component under:
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 |
|
| root element of the form definition |
|
| root element of the form definition's form instance |
|
| root element of the form definition's form metadata |
|
| all data holders for the given control |
In addition, fb-initialize
takes the following parameters:
Parameter Name | Type | Value |
|
| original control id, such as |
|
| original control name, such as |
In addition, fb-apply
takes the following parameters:
Parameter Name | Type | Value |
|
| new control name, such as |
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 updated