Creating XForms Widgets

Showing results for 
Search instead for 
Did you mean: 

Creating XForms Widgets

0 0 1,401

Obsolete Pages{{Obsolete}}

The official documentation is at:


Form Construction Process

When a user requests a web form, an XForm is dynamically generated from the XML schema, and any dynamic includes / imports listed in the XML Schema are executed.  The XForm is then interpreted to produce an HTML form, which is presented to the user and used to capture the data that ends up in the XML document saved into the repository.

There are three extension points in this process:

  1. Use of dynamic includes/imports to generate portions of the source XML Schema (see WCM Forms Authoring Guide#Using dynamic types in schemas for more details)
  2. Customization of the label, alert message and widget for a given field in the XML Schema (see WCM Forms Authoring Guide#XForm User interface customization for more details)
  3. Ability to add custom widgets to the library of widgets available for use in Web Forms

Implementing Custom Widgets

Alfresco ships with most common widgets you'd expect in a Web CMS, including single- and multi- line text editors, an HTML editor, a date picker, option and radio buttons, drop down lists etc.  However there are cases where you may need a custom widget, for example to perform lookups in some external system.  Alfresco Web Forms leverage the widget mechanism of the Dojo Javascript framework for all field-level widgets - creating a custom Alfresco Web Form widget involves developing a custom Dojo widget and then registering it with Alfresco for use in Web Forms.

Detailing how Dojo widgets are implemented is beyond the scope of this document, however Alfresco recommends a two step process for developing and integrating custom Dojo widgets into Alfresco:

  1. Develop and test the widget outside of Alfresco (for example in a static HTML page)
  2. Integrate the tested widget into Alfresco and test it in a Web Form

Integrating a custom Dojo widget into Alfresco involves:

  1. Adding your custom widget definition to xforms.js (located in the /scripts/ajax/ directory in alfresco.war)
  2. Registering the new widget with Alfresco in web-client-config-wcm.xml (located in the /WEB-INF/classes/alfresco/ directory in alfresco.war), giving it a symbolic name as part of that process
  3. Updating your Web Form XML Schema(s) to use your custom widget, by putting the widget's symbolic name in the 'appearance' annotation of the relevant element(s)

Note that the registration process is currently not as clean as it should be and will be improved in a future version of Alfresco - JIRA tickets WCM-786 and WCM-1045 are tracking these issues.

Return to WCM Forms Developer Guide