Daisy documentation
 PreviousHomeNext 
5.16.3 Implementation infoBook Index5.17.2 Implementation info

5.17 Field editors

5.17.1 Configuration

Detection of the field editors is done when the document editor is started. Each field on the document is checked to see if an editor is available. If no editor is configured the default field editor will be used. This editor is configured based on which field type it is handeling.

When you wish to use a custom field editor you start by creating a configuration file. The file name should be of the format <fieldTypeName>.xml and it should be found in the following directory :

<wikidata directory>/resources/fieldeditors/

The configuration file is expected to contain XML of the following format :

<?xml version="1.0"?>
<fieldEditor xmlns="http://outerx.org/daisy/1.0#fieldeditor"
        class="...">
  <properties>
    <entry key="...">...</entry>
  </properties>
</fieldEditor>

The class property of the fieldEditor element should contain the class name of a class implementing the following interface:

org.outerj.daisy.frontend.editor.FieldEditorFactory

The properties element is optional and can be used to configure the field editor.

Currently the only editor shipped with Daisy is the DefaultFieldEditor. Lets say that you wanted to hard-bind this editor to a field type you'd do it like this : (of course there is no need to do any of this just serves as an example)

Create a file called MyFieldType.xml in the <wikidata directory>/resources/fieldeditors directory with the following content.

<?xml version="1.0"?>
<fieldEditor xmlns="http://outerx.org/daisy/1.0#fieldeditor"
	class="org.outerj.daisy.frontend.editor.DefaultFieldEditor$Factory"/>

This editor will be used next time you edit a document using the MyFieldType field type.

In some cases all you want to do is customize the cforms template and the cforms definition.  This can be done without implementing a FieldEditor by specifying properties to the DefaultFieldEditor:

<?xml version="1.0"?>
<fieldEditor xmlns="http://outerx.org/daisy/1.0#fieldeditor"
	class="org.outerj.daisy.frontend.editor.DefaultFieldEditor$Factory">
  <properties>
    <!-- override the default cforms-definition stylesheet (resources/xslt/fieldtype_to_widgetdefinition.xsl) -->
    <entry key="definition">wikidata:resources/formfragments/myfieldtype_definition.xsl</entry>

    <!-- override the default cforms-template stylesheet (resources/xslt/fieldtype_to_widgettemplate.xsl) -->
    <entry key="template">wikidata:resources/formfragments/myfieldtype_template.xsl</entry>
  </properties>
</fieldEditor>
 PreviousHomeNext 
5.16.3 Implementation info5.17.2 Implementation info