Extension API
Last updated
Last updated
Since Orbeon Forms 2016.1.
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.
First, make sure you have chosen a prefix-to-namespace mapping for your components, as explained in .
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
.
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 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
)
You then create the file implementing the component under:
Here is a template for the new XBL component:
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.
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
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 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
)
You then create the file implementing the component under:
For an example template, see above for acme:form-settings
.
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.
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.
For more on XBL components, see .
For instance, see , 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.