Posts filed under ‘betterFORM’

Ann: eXist-db 2.0 released

Why this news on the betterFORM blog?

The answer is simple: eXist Solutions (the company behind eXist-db) and betterFORM have joined forces to integrate their two long-standing projects and offer commercial support for this new platform. As true Open Sourcers we’ll continue to offer this new product as free, Open Source software. Not much change here. But additionally there now will be subscription-based support for those that need long-term reliability for their commercial applications.

Beyond having integrated our products to work seamlessly with each other we have also joined our skill set and experience in the XML domain. We offer this joint expertise to our customers as consulting, development and training services to enable them to build better applications in less time.

See the new eXist-db homepage for details.

February 11, 2013 at 12:29 pm Leave a comment

Taking MIPs to the next level

Since: betterFORM 5.0rc1 – buildNumber:11612

Model Item Properties (MIPs) are one of the central features of XForms. In short they allow to add constraints to XML nodes. The available MIPs are:

  • readonly – boolean XPath expression
  • required – boolean XPath expression
  • calculate – XPath expression
  • relevant – boolean XPath expression
  • constraint – boolean XPath expression
  • type – XML Schema simple datatype or extension thereof

However with XForms 1.1 each of these MIPs were allowed to be attached to a node only once. If a bind element happened to attach one MIP to same node a second time the processor would throw a XFormsBindingException.

This was rather limiting expecially with respect to the ‘constraint’ MIP as in practice it often happens that you’d like to test for more than one condition. Of course you can combine conditions with a simple ‘and’ like so:

<xf:bind nodeset="a" constraint=". &gt; 5 and .  &lt; 10" />

But this leads to long and hard to read expressions. Wouldn’t it be much nicer to be able to write:

<xf:bind nodeset="a" constraint=". &gt; 5" />
<xf:bind nodeset="a" constraint=". &lt; 10" />

MIPs in XForms 2.0…

This is exactly what is addressed in the upcoming XForms 2.0. It now allows that one and the same MIP is attached to the same node several time and defines some combination rules. This table was taken from the current XForms 2.0 Draft.

property combination
type* all
constraint all
relevant all
required one
readonly one
calculate not allowed
p3ptype not allowed

*To be honest we still couldn’t make much sense out of the fact that the ‘type’ MIP is also allowed to be combined as the use cases seem to be rather exotic. But probably it just lacks a good example. For the time being we haven’t considered that in our implementation.

‘all’ means that all conditions are chained with a boolean ‘and’ so all conditions must become true for the constraint validation to become true. ‘one’ on the other hand combines the statement with boolean ‘or’.

…and beyond

The combination rules for ‘constraint’, ‘relevant’, ‘required’ and ‘readonly’ are now implemented in betterFORM. But we went some steps further and also picked up some of the ideas from a  post published under the name ‘MIP Names, Type, Etc.’ on the W3C XForms group wiki.

Besides using the syntax shown above you are now able to write the following statements:

<xf:bind ref="a">
    <bf:constraint  value=". &gt; 5"/>
    <bf:constraint value=". &lt; 10" />

The custom element ‘constraint’ in the betterFORM namespace is an alternative notation that allows some interesting options beyond making the markup even more readable. See this:

<xf:bind ref="a">
    <bf:constraint  value=". &gt; 5">
        <xf:alert>The value must be bigger than 5</xf:alert>
    <bf:constraint value=". &lt; 10" >
        <xf:alert>The value must be smaller than 10</xf:alert>

Here we find our good old friend the ‘alert’ element which XForms authors know as one of the child elements of XForms controls to signal an error. The alerts are now attached to a single constraint MIP and allow to tell the user exactly which of multiple constraints has failed in a given situation.

But there’s even more. In some situations even a single condition might be complicated and therefore hard to read. This is especially true when it’s crammed into an attribute. Now you can also write:

<xf:bind ref="a">
            my really long and complicated 
            possibly multiline XPath
        <xf:alert>The value must be bigger than 5</xf:alert>

Besides for constraint also


are  supported and useable in the same way.

Of course the new custom syntax fully harmonizes with the standard syntax so the following will be perfectly valid:

<xf:bind ref="a">
    <bf:constraint  value=". &gt; 5">
        <xf:alert>The value must be bigger than 5</xf:alert>
<xf:bind nodeset="a" constraint=". &lt; 10"/>

One Question left

Great, now we have the ability to signal to the user what exactly went wrong, combine several occurrences of a MIP and we can trigger each UI control bound to that node. But what if we do not want that? It might be even confusing if alert messages pop up in the UI at several places.

So we need a mechanism to selectively and explicitly say that we want an error to be displayed for a given control. We currently solved this like so:

<xf:input ref="a">
    <xf:label>a text</xf:label>
    <xf:alert srcBind="aBind"/>

‘srcBind’ is an idref and points to an existing bind with id=’aBind’. This is taken as the root element for all alerts that might be displayed (if their respective constraint fails) or not displayed (if their respective constraint passes). The xf:alert in the UI becomes a container for all messages whose constraint fails and are displayed as a stack.


We hope these extensions are useful and welcome your feedback.

December 19, 2012 at 1:32 am 1 comment

bf:include – an alternative to XInclude

Since: betterFORM 5.0rc1 – buildNumber:11523
Author: Lars Wndauer

When building applications with many forms and especially when using a lot of subforms you’re often facing a lot of markup redundancy. This article shows a new utility in betterFORM to avoid such redundant parts thereby making your applications more maintainable.

In the XML world there is the well-known XInclude specification that handles includes in the XML markup language. However this specification only handles very simple file inclusions. If you have more fine-grained snippets to assemble you have to go for XPointer in addition which has unfortunately some shortcomings – it’s simply not or only partly implemented in many environments and has a somewhat crude syntax.

This article shows a more pragmatic approach which has been developed by the betterFORM team during its work on a large customer project.

Example 1 – simple inclusion 

    <xf:instance id="i-contacts" src="data/contacts.xml"/>
    <bf:include src="templates/binds-contacts.xml"/>

This isn’t differnt to what you would get from XInclude. It simply includes a complete file and replaces the <bf:include /> tag with that.

If authors don’t want to create a bind file for any group of binds but to manage them in a single file this is possible as well. Imagine a bind.xml as shown in example 2.

Example 2 – inclusion of a specific element

This example goes one step further allowing you to address a specific id in the referenced file. Consider the XML snippet below:

  <bind id="b-contacts" nodeset="contacts">
      <bind nodeset="user/@shortname" constraint="string-length(.) &gt; 5" />
  <bind id="b-events" nodeset="contacts">

To reference the “b-contact” bind in your form simply use the fragment identifier on the URI: <bf:include src=”templates/binds.xml#b-contacts />.

This technique already allows to group similar contents together in one file but to use them in different contexts.

Form authors will quickly see how useful this small extension is, but they will also notice that in the real world things are often not as easy as this. Consider example 3.

Example 3 – add some markup to the inclusion

Often when building large form applications with XForms you’re facing markup that is largely the same in different contexts. This is especially true with many submissions that load the same data in different parts of the application. But you have to repeat the whole block just to add a different a different error-handler as the message in the example below:

<xf:submission id="s-load-data" resource="context:payload" method="get" replace="instance" instance="i-default">
      <xf:message id="load-data-error-handler" ev:event="xforms-submit-error" ref="instance('i-lang')/msg[@key='submissionLoadError']"/>

To handle this use case the bf:include mechanism provides an additional bf:action attribute that can be used to add some markup.

This can be achieved with the following markup:

<bf:include src="templates/submission.xml#s-load-data">
    <xf:message bf:action="append" id="load-data-error-handler" ev:event="xforms-submit-error" (...)

Please note the bf:action attribute here. This tells the engine to append the xf:message element to the included submission with id=”s-load-data”.

Extend Included Markup

Markup included via bf:include can easily be extended using the bf:action attribute. Example 4 shows how the bf:action attribute value “append” is used to chain a submission transforming the instance data to the “s-load-data” submission.

Example 4 – Append 

<bf:include src="templates/submission.xml#s-load-data">
   <xf:send bf:action="append" ev:event="xforms-submit-done"  submission="s-transform-data"/>

Overwrite Included Markup

Another scenario that comes up quite often is that a single piece of the included markup must be overwritten with some other markup. Example 5 shows how this can be achieved. Here the error message from example 3 is overwritten with another error submission handler:

<bf:include src="templates/submission.xml#s-load-data">
   <xf:send id="load-data-error-handler" bf:action="overwrite" ev:event="xforms-submit-done"  submission="s-error-handler"/>

It should be noted that this inclusion mechanism can be applied at deploy- or runtime. If you want to apply inclusions at runtime you have to configure betterFORM to do so by editing the betterform-config.xml file and setting the property “webprocessor.doIncludes” to “true”.


No question bf:include especially in combination with the XForms subforms mechanism is a powerful technique for form authors when writing maintainable enterprise applications.  The bf:action attributes will be available in the upcoming betterFORM 5 release. If you can’t wait simply check out the betterFORM development branch at and get started.

Note: the inclusion is currently still not yet integrated within the build process of betterFORM. This will follow at a later stage.

November 10, 2012 at 5:14 pm Leave a comment

XML Summer School is using betterFORM

The XML Summer School is now using the eXist XML database and betterFORM for their trainings. They have setup a demo application which allows the students to experience the power of XML. Here’s a screenshot of this application:

The teaching application itself is Open Source and can be downloaded from sourceforge.

September 19, 2011 at 2:49 pm Leave a comment

Getting started with betterFORM limeGreen

This post guides you through the first steps of installing, running and using betterFORM limeGreen. Though betterFORM can be run in a variety of deployments and configurations this document focusses on betterFORM XRX. This is a bundling of the eXistDB XML database with betterFORM in a ready-to-run configuration along with a dashboard to help you manage your applications.


  • Java 1.5 installed on your system


Before you start you need an installation of betterFORM XRX.

  1. Goto the sourceforge download page and get the latest version. This will download the betterFORM installer.
  2. After the download is finished double-click the betterform-install.jar to open it. Please note that Java must be installed on your system and jar files must be configured as executable (which is the case by default).
  3. After you have accepted the license terms and specified the installation directory you will presented with some readme information. Skip that screen to get into the package selection.

select the packages to install

The installer will offer several different options for betterFORM:

  • installation of a WAR for direct deployment into your webcontainer
  • betterFORM standalone bundles the Jetty webcontainer and comes with a graphical application starter
  • betterFORM XRX which integrates betterFORM with eXistDB as a standalone application platform

For the scope of this article we deal with betterFORM XRX which is already selected by default in the installer. Just hit the ‘Next’ button to go to installation screen.

During this step the betterFORM will be installed on your disk.

The following screen lets you choose a password for the ‘admin’ user. Please memorize this password as otherwise you’ll be locked out of the database. If you are just test-driving you may leave the password empty.

After this is done hit ‘Next’ a last time to finish the installer.

Running betterFORM

In standalone (Jetty) and XRX mode betterFORM can be run via a Java executable jar. To run it double-click it in your favorite file browser or execute the following command line:

>java -jar betterform.jar

A small application with betterFORM logo will appear.

Clicking on the icon will run your default web browser with the entry page.


betterFORM limeGreen now comes with a new facility for managing your XForms application resources like XForms documents, CSS and JavaScript files, XQueries and transformations, images etc.

The ‘Dashboard’ will be the default entry page when you browse a new betterFORM installation. Besides browsing and running the XForms, you can add files and collections to your application and view the source.

Feature Explorer

One of the items found on the Dashboard root level is the Feature Explorer. It is the central location for running the reference forms of betterFORM. They serve as a live documentation of XForms and betterFORM features and show you working markup examples and the rendered output.

Some of the pages will have links to the respective sections in the XForms 1.1 Recommendation and the XForms 1.1 Quick Reference documents for quick lookup of syntax details.

On the right hand there is a  CSS reference that highlights the matched elements when hovered.

The Feature Explorer will be extended with further examples as new features become available.

Under the hood Feature Explorer makes heavy use of form embedding. All embedded forms can also be run standalone by browsing the ‘reference’ collection with the Dashboard and clicking on the respective link.

Running the XRX demo application

Start your browser and goto:http://localhost:8080/betterform/rest/db/betterform/apps/timetracker/index.xql or execute index.xql from Dashboard. This should show you a screen like this:

Timetracker XRX demo application

Please note that this is only the first version (0.1) of the application and we plan to continuously extend it to show more features and solution patterns. Therefore not all menu buttons are already working.

Please use the ‘filter’ to select a start date before 01. June 2010 to see all the sample data.

What Timetracker does

TimeTracker is a simple application to track the time spend on a project and we use it internally log our working hours. As such TimeTracker gathers small XML files in a database collection and allows to create, edit, delete and filter those entries. The whole application consists of a bunch of files organized in a collection hierarchy stored in the database.

TimeTracker uses XForms, REST and XQuery to model a complete application. The XForms are generated by XQuery code and XForms embedding is used to assemble the different documents into one single-page application. The data can be filtered by several criteria and are returned as a plain HTML table. The table is then embedded into the main page of the application (index.xql).

filtering tasks in TimeTracker

A single entry in our time tracking is represented by a ‘task’. Tasks are always shown for the selected date range which is displayed in the upper right. By choosing the ‘Filter’ button from the toolbar you can change the displayed date range. Please play with the filter fields to see more or less entries. The form selects a default date range that starts 30 days before today.

A first glimpse behind the scenes

To see the gears TimeTracker was made of it’s best to use the eXistDB Java admin client and take a look into the XQueries and XForms that make up the application. To access the admin client please first goto http://localhost:8080/betterform. In the right upper corner of the Dashboard you find a blue button with an eXist icon. Hit that button and the admin client will download and start automatically.

After you have confirmed the execution of the admin client the following screen will be presented:

eXistDB admin client login

Please use the password you have choosen during install to login and close the dialog. Otherwise the application will not show up.

Go to collection ‘betterform/apps/timetracker’. This is the root collection of the application. You can directly access any file or collection by double-clicking on it. You should start your investigation with ‘index.xql’ with is the main page of the application. All other documents or generated contents will be embedded dynamically into this page. index.xql is simply an XForms document wrapped as an XQuery. XQuery does not do anything here. It’s just to see it’s possible 😉 Instead we could have just stored a XHTML document here.

Further files of interest are ‘edit/edit-item.xql‘ which is the creation and editing form for the application and ‘list-items.xql’ which is responsible for generating the results table. You will find some more files in the database and not all of them are already active.

This is only a first glimpse on the application and betterFORM XRX. A follow-up post will go more into the technical details of how the pieces fit together and show how easy and powerful the combination of XForms REST and XQuery is.

February 24, 2011 at 3:18 pm 1 comment

What’s new in betterFORM limegreen

Release Notes

These are the release notes for  betterFORM limeGreen (4.0).

New features

Event Log

In previous versions of betterFORM event logging was available on the Firebug console (or its respective counterparts in Chrome and Safari). However this worked only for the uncompressed version of betterFORM as it relied on the console.debug feature of those tools.

In betterFORM limeGreen 4.0 there is a new event log that helps tracking the events exchanged between browser and XForms processor on the server regardless of the mode of operation. It is enabled by configuring the debug option in betterform-config.xml like this:

<property name="betterform.debug-allowed" value="true" description="if true enables debug bar and event log viewer"/>

When active there will be a small icon in the upper right of the browser window. Clicking on that will reveal the event log.

In the event log each event that is received from the server will be listed with all of its context information. In some cases where an targetElement or targetId is given you can click on a link and the respective element in the browser will be highlighted in blue.

The icon in the upper right will allow to expand or collapse the event log while the trash bin icon allows to remove all entries from the log.







Error Highlighting

One of the most common errors when authoring forms is to produce a xforms-binding-exception. In complex forms these can be hard to locate. The new error highlighting feature improves this by giving you the exact line in your markup where your binding exception occurs.

Sample image illustrating the error highlighting feature

In addition to the markup the requested URL and the exact XPath for the problematic element is shown.

Syntax Highlighting for Host and Instance Documents

The debug bar has been enhanced to now show the host and instance documents syntax highlighted too. Here’s an example:

sample of syntax highlighted host document

Configurable Position for Ephemeral Messages

betterFORM uses a Dojox toaster control for displaying ephemeral message. These were always shown at the bottom of the screen. The position for these messages is now configurable by adding an attribute to the root node of the document:

<html xmlns=”;

The toaster position now can be any of the four corners of the browser window. Valid values for the attribute ‘bf:toaster-position’ are documented in the Dojo docs.

Automated Web Tests

Not strictly a new feature but we have started to automate cross-browser testing by using the new Selenium webdriver. We have already implemented a lot of tests which are now run twice a day to reveal potential regression bugs. The test assertions will be expressed in an XML format to ease the implementation of tests. From these definitions the Java code for Selenium will be generated. The tests may then be run against different browsers. We will continue to add tests and probably make the testing infrastructure available for developers that like to do their own tests.

Moved to Less for CSS Styling

LESS has a growing popularity for doing complex CSS layouts. Check out their website for an overview of the features. We decided to move all relevant CSS stylesheets to LESS as it is much more expressive than CSS and e.g. allows variables to avoid redundancies. LESS files get compiled into standard CSS so there are new dependencies at runtime nor restrictions on the use of ‘normal’ CSS files.

XForms Editor Preview (RC 2)

Starting with RC 2 there will be a new XForms editor in betterFORM. It will be (not in the first place) wysiwyg page editor but a pure XForms 1.1 editor which allows to edit all XForms markup contained in some (X)HTML document. It focusses on the abstract view of XForms authoring and assists to keep your markup clean and consistent. Large parts of the editor are generated directly from the XForms 1.1 schema thus supporting the full set of XForms elements and attributes plus the XML Events schema.

The first version will give access to the complete XForms language vocabulary unfiltered and will mainly target more experienced XForms authors. Starting from there ‘profiles’ will allow to filter and change the representation of the attribute editors and add authoring convenience functions.

After ‘expert mode’ (above) a ‘basic mode’ is planned as an alternative view for non-XForms users. This will works with implicit instances (instance nodes created on the fly) and smart defaults for quick editing without all the rarely used features.

What’s already working:

  • parsing of any XHTML/XForms document and opening it in the editor. Only XForms markup will be shown.
  • expandable/collapsible (tree-like) view of the XForms markup
  • schema-aware sidebar that shows only possible children and siblings for a given element
  • schema-aware dnd – still a bit quirky but allows to move elements in the tree
  • schema-aware moving of elements by keyboard shortcut (this works really nice)
  • ‘attribute panes’ with all possible attributes of a given XForms element which update the markup tree
  • inserting and deleting of all XForms elements
  • serializing changes
  • applying changes to original input document
  • preview, save + save as

We hope to create a tool for XForms authors to create fully valid XForms documents and appreciate all comments and suggestions. Contributors welcome.


To simplify the setup of projects using betterFORM XRX there’s a new helper build tool called ‘ProjectAssistant’. It helps to keep your project sources separate from the betterFORM sources while still giving access to the full functionality of the complete source tree. It also allows to easily switch to a newer version of betterFORM as soon as it becomes available.

Google App Engine (RC 2) (revised)

betterFORM can now be deployed on Google App Engine and thus be run in the cloud.

There are still some detail issues to be solved to actually make it happen. We’ll continue to work on that.

Work on this has been stopped due to lack of resources and seemingly lack of interest. If someone likes this to become part of betterFORM please speak up on the mailing-list.

Windows Installer (RC 3)

There is a new Windows installer packaged as an .exe file to make installation for Windows users even easier.

Single-jar deployment (RC 2)

Starting with Release Candidate 2 betterFORM will default to using a single-jar deployment. This means that all Java classes plus all the needed resources  (CSS, js, image and xsl files) will be packaged in a single-jar file that can easily be added to a web application. The jar will contain an optimized version of the JavaScript used in betterFORM and the overall size of the archive will be about 2.7 megs.

A new resource handler allows to turn caching on and off.

betterFORM XRX extension for eXist

We are very happy to announce that we now have a tight cooperation with the eXist project and directly commit the XRX extension to the eXist trunk. However we will continue to offer our own eXist/betterFORM bundle as a ready-made installer packed with the latest stable version of eXist.

One hotspot of our activities was to refine the eXist integration and to fix the issues that existed in the former release. There were some inconsistencies and shortcomings of that release and we think we have finally sorted those out. Configuration and installation should now be smooth.

We also concentrated on making the betterFORM extension a good starting point for building XRX applications that are stored completely in the database. There also will be a browsing tool that lets you browse, execute and view the sources of all of your app files. Additionally you can upload files to the database and create new collections as needed.


The betterFORM Dashboard is the new starting point when working with betterFORM. It replaces the simple form.jsp of former versions and allows to mange your XForms documents along with their resources (CSS, images, static HTML, JavaScript) in one place. Dashboard works on both pure webapps with filesystem storage or as collection browser for a XRX application on eXistDB.

betterFORM dashboard

Dashboard supports the XML application developer and XForms author in working with their resources. It lets you browse the hierarchical structure of your applications, create new collections, upload files and view the source-code. It will also allow to start the XForms editor with an additional button.

Dojo Upgrade (revised again)

Dojo 1.5 is now integrated. All Dojo themes (tundra, soria, nihil and claro) can now be used in the forms. While we are working on the release a new release (1.6) has become available. We’ll upgrade before final release.

The Dojo Foundation has released version 1.6 while we were working on our release. We have upgraded to that version without issues so now Dojo 1.6.1 will be part of limeGreen and allows to use the latest and greatest of Dojo.

Dojo 1.7 is already on the horizon (first betas are out). We’ll probably upgrade again if it becomes final before betterFORM limeGreen final is released.

Finer grained Dojo builds

There are finer grained Dojo profiles now for building optimized JavaScript files to reduce the size and amount of downloaded resources. Besides a minimal, medium and full profile it’s now also possible to build optimized JavaScript files for a specific page.

Attribute Value Tempate (AVT) support

AVTs are now fully supported on foreign elements (typically HTML). That means you can use XPath expression in any HTML attribute for instance class=”{foo/bar}” will evaluate the XPath according to the XForms in-scope context rules allowing you to manipulate the rendering of HTML from XForms.

New Submission modes

There are two new submission modes:

  • a submission @replace=”embedHTML” now allows to embed HTML markup in your current document. You typically might want to use that to call some URL that produces HTML markup by templating  (e.g. long output tables to display data). HTML can also be embedded by using a xf:load action but a submission gives you finer-grained control of your request (sending data if needed, validated or not, setting headers, error-handling etc.)
  • a submission @replace=”new” allows to open the result of a submission in a new window. Please note that this functionality has been accepted by the XForms WG as a new feature though with a different syntax. We’ll adapt to that syntax in a later release. Typical use case is the display of printable views.

XPath Functions

The Java classes implementing the XPath functions for XForms have substantially been refactored for easier extensibility. This is an important preparation for allowing users again to configure a new Java function library.

dispatch action supports custom contextinfo

The dispatch action now can take custom contextinfo. This is useful in context with subforms when single values shall be exchanged between models. An example illustrates that best. Assuming the action below is in scope of model A it may send either a static value or a pointer to an instance node value to model B with:

<xf:dispatch name="customEvent" targetid="foo">
    <xf:contextinfo name="param1" value="'hello'"/>
    <xf:contextinfo name="param2" value="value"/>

<group model="B" id="foo">
    <xf:action ev:event="customEvent">
        <xf:setvalue ref="staticResult" value="event('param1')"/>
        <xf:setvalue ref="xpathResult" value="event('param2')"/>

Context connector

There is a new connector with the scheme ‘context:’ that allows to store an instance into a hashmap of the XForms processor. This is a handy feature when composing wizard-style forms that are made of subforms and need to pass instance data back and forth. As the same XForms processor instance will be used over the live-time of the embedding document this can act as a global data-container for subforms.

SSL handling

SSL handling has been refined allowing a pluggable SocketFactory to be used. Details of the keystore can be configured in betterform-config and a howto has been added to the docs.

Multiple Labels

A control now may have multiple labels for different languages. This gives an easy alternative for quickly internationalizing forms. It’s planned to extend that approach for alerts.

Modal messages

Model message are now rendered as Dojo dialogs and fit into the respective Dojo theme that is used.

This change needed to be rolled back as there were problems in some rare conditions with the handling of focus events.

Event reduction

The amount of events propagated to the client have been reduced dramatically. From now on only events that really have been used in a form will be propagated over the net.

XForms Inspector (revised)

There already was a feature allowing to view XForms instances at runtime in a Firebug console. But the solution had some shortcomings:

  • you needed to run on Firefox with Firebug plugin to see the instances
  • it was not obvious to users that you had to add a ‘?debug’ to the form URI to get the buttons
  • and worst it did not show the instances of embedded models as these could change at runtime

The new solution still requires that you activate the ‘debug’ feature in the betterform-config.xml but is now independent of Firefox and Firebug. Once activated a bar is rendered at the bottom containing one link to see the host DOM as it exists on the server (pre-transform) as well as one link for each instance in each model. The links update if a model becomes available by embedding or is removed from the document by unloading.

The XForms inspector can now be collapsed to an icon to avoid hiding elements on the page.

XForms Dialog

we now implement the proposal for the dialog element along with its show and hide actions.


There is a new XFormsPostServlet to allow initialization of a XForms from a http POST containing xforms markup in the body.

XForms Feature Explorer / Reference

The XForms Feature Explorer serves as a live reference for XForms and betterFORM. It has been completely overhauled and given a clean structure with description (with spec links), live example and source code. Alongside of that you will see which CSS classes that apply in the respective context and can even see them at work when hovering the class name. New sample forms have been added beyond the basic control and container documentation.

Here is a screenshot of one reference form:

Screenshot of one reference form

Automatic CSS import for subforms

CSS style rules that are present in a document that is embedded will now get imported into the embedding document. Currently only style elements are handled but this still allows usage of external CSS files by using the @import instruction.

Automatic JavaScript import for subforms (RC 2)

Similar to CSS resources JavaScript blocks and linked JavaScript files from the head of the embedded document can be imported in the embedding document.

Refined user agent configuration

The betterform-config.xml now allows to configure a new user agent along with its supporting Java class and a XSLT transform.

Resource pathes

The handling of resource pathes has been simplified. Instead of having multiple pathes for CSS, scripts etc. there’s now only one for the resource root dir which is configurable in betterform-config.xml.

Saxon upgrade

The XPath processor is now using Saxon

Http Client update (RC2)

The http client has been upgraded to latest version of HttpComponents (formely Apache Commons HttpClient).


Java code level logging has been refined in many areas now giving you more fine-grained control on the level of detail you’d like to log. Instead of just ‘debug’ we are now making use of the ‘trace’ level which produces much better readable output.

Configurable delay for incremental

Each control may now have an additional delay for the firing of incremental events. If delay is 0 there will be one event for each keypress while a control has focus. A bigger value will defer the firing for the specified time in milliseconds.

Refined alerts and hints

The default behavior for alerts and hints has been reworked. As the default now inline alerts and hints will be used. Hints will show when a control gets focus. Whenever a control gets invalid the alert will show in the same place as the hint (covering it). Alerts can be closed by clicking on them in case they cover other fields in a complex layout. The CSS for these child elements has been stabilized and works with horizontal and vertical layouts.

New alternative date control

There’s a new date control consisting of three dropdown controls instead of the datepicker popup.

Restructured XSLT transforms (RC 2)

The XSLT stylesheets responsible for the transformation from XForms to HTML have been completely overhauled for easier maintainability and extensibility. The base stylesheet now again produces native controls which can be overwritten to add functionality like scripting. As a result the overall stylesheets are more modular, smaller and easier to enhance.

Fixed Issues

  • fixed various problems with stale UI Events leading to repeating alert messages in the browser
  • an issue with downloading of schemas from the internet has been fixed (Ticket #40)
  • a hard-to-catch race condition with the ajax calls was fixed that only shows under heavy test conditions. Now the client-side uses a fifo buffer to make sure all events are processed in right order and even is able to discard events that may have become irrelevant in the meantime through network delays.
  • the style attribute was not handled correctly in all places. This is fixed now. (Ticket #28)
  • some issues regarding focus events (especially group and repeat focus events) have been addressed.
  • fixed naming inconsistencies of betterFORM CSS classes (Ticket #26)
  • fixed a problem with loosing trailing zeros during localization
  • Issue with betterform-index-changed events fix (Ticket #74)
  • fixed trailing zero problem for internationaized values (Ticket #73)
  • added missing xfValue class to triggers (Ticket #19)
  • fixed missing xforms-in-range event for select control (Ticket #48)
  • clarified issue with potential CSRF attacks in Tomcat 7 (Ticket #30)
  • clarified issue with Weblogic 10.3 (Ticket #81)
  • fixed broken Rating control (Ticket #39)
  • fixed problem with alert in secret elements (Ticket #66)
  • fixed problem with sum() function working on invaid nodes (Ticket #61)
  • fixed issue when ehcache is not configured properly (Ticket #103)
  • re-introduced xfRequiredEmpty class that signals required but empty fields after a submission error (Ticket #110)
  • slider problems in IE9 have been fixed (Ticket #140)
  • a problem with large localised decimals has been fixed (Ticket #150)
  • a problem with setting of context params has been fixed (Ticket #139)
  • plus several dozens of minor changes
  • a problem with the context() function has been fixed (Ticket #29)
  • a problem with the validation on long decimals has been fixed (Ticket #150)
  • handling of upload in eXist integration has been fixed (Ticket #133)
  • a problem with ‘selection=open’ has been fixed (Ticket #116)
  • broken DOMFocusIn handling has been fixed (Ticket #156)
  • @value on Element value not working was fixed (Ticket #42)
  • SSL now may use Java provided keystone (Ticket #154)
  • event() function not evaluating has been fixed (Ticket #146)
  • namespace in submitted instance now behave spec-conformant (Ticket #130)
  • selection=”open” in repeats now works correctly (Ticket #157)
  • enhanced / fixed handling of HTTP headers
  • fixed problem with setfocus action not setting the focus in some situations
  • enhanced error information for exceptions
  • upgraded to Xerces 2.11
  • fixed problem with JavaScript in model actions (Ticket #203)
  • fixed ranges within repeats (Ticket #201)
  • fixed missing support for choice labels (Ticket #195)
  • fixed problem with dependant lists in IE8 (Ticket #192)
  • fixed escaping problem with entities (Ticket #193)
  • fixed problem with params on instance @src attributes (Ticket #189)
  • fixed bug with positioning of tooltip alerts (Ticket #198)
  • added a TimePicker implementation (Ticket #178)
  • fixed issue with html default namespace
Besides the above dozens of smaller issues have been addressed. For a detailed list please visit or check the commit history on Github.

January 20, 2011 at 9:00 pm 1 comment

Using Subforms with betterFORM

This article gives a short introduction to using subforms with betterFORM. Before going into details it should be clarifed what is meant when talking about subforms. Subforms are complete self-contained pieces of markup consisting of a XForms model and its associated UI that are loaded at runtime with the help of the XForms load action.

In the majority of cases XForms markup is embedded inside a XHTML document (other markup languages are of course also possible as host document). In this respect subforms don’t differ from ‘normal’ XForms documents.

However we use a convention for the structure of the document: we put the XForms model and user interface into one div within the body of the document like so:

<head><title>A sample form</title></head>
    <div id="xforms">
        <xf:model id="mymodel">

This is perfectly in sync with the XForms Spec. It’s a mere convention that some people put their models into the head section. Putting both the model and the UI into a div in the body just makes it easier to embed the form in one go instead of needing two or more instructions. It may be advisable to wrap the model in another div and hide it from the browser with style=”display:none;” (not shown here). This avoids that the browser chokes on the unexpected XML markup.

A complete example illustrate best how easy it is to use subforms. The following piece of code shows how to use the XForms load action to embed a complete XForms model:

<html xmlns=""
     <title>an embed sample</title>
    <xf:model id="model">
      <xf:instance xmlns="">
      <div id="embeddedForm"/>
      <xf:trigger id="trigger-load-embed">
        <xf:label>Load embedded Form</xf:label>
          <xf:load show="embed" targetid="embeddedForm">
            <xf:resource value="'EmbeddedForm.xhtml#xforms'"/>

There are a few things worth pointing out. First note the <div id=’embeddedForm’/>. This is be the element that gets replaced by the subform once the trigger has been activated. Second, look closely at the <load> element. While XForms only know the values ‘new’ and ‘replace’ for the show attribute betterFORM also handles the value ’embed’. The additional attribute ‘targetid’ specifies an idref to the element that will get replaced by this action. The resource element finally specifies the subform document. The fragment identifier (‘#xforms’) is another idref pointing to the target element within that document. By using a fragment identifier it is possible that the subform resides in its own complete document and can be run and tested independently from the embedding document.

The following things happen when the load action is run:

  • the resource will get loaded and parsed as XML
  • the element denoted by the ‘targetid’ attribute will be extracted
  • the resulting subtree is imported into the calling document
  • the XForms processor will initialize the subform by looking for models within the loaded markup
  • the lifecycle events defined by XForms (model-construct, model-construct-done and xforms-ready) are dispatched to initialize the subform just as any ‘normal’ form
  • the subform will be rendered as part of the original page calling the load

Once you have loaded a subform you will probably want to get rid of it later when its purpose is done. This can easily be done with the following markup:

<xf:load show="none" targetid="embeddedFom"/>


  • working with subforms allows easier authoring and testing of large form-based applications
  • loading of subforms is fast as they are processed by just one instance of a XForms processor
  • resource consumption is much lower compared with big forms that use a XForms switch to show / hide specific views


  • this extension of the load action is not yet part of the XForms standard but hopefully will become in one of the future versions

A more in-depth documentation of this feature can be found in the betterFORM User Guide.

August 16, 2010 at 4:34 pm 2 comments

Older Posts

Recent Posts

betterFORM tweets

%d bloggers like this: