Daisy documentation
 PreviousHomeNext 
5.17 Field editorsBook Index5.18 Internationalisation

5.17.2 Implementation info

The Daisy document editor is actually a bunch of forms that are implemented using CForms(Cocoon Forms). The fields tab in the editor is just one  such a form. Each field type corresponds with one widget on the form. This means that every instance of the FieldEditor interface needs to generate pieces of form definition and form template. Each generated piece is then aggregated into one big form.

When implementing a new field editor you can extend the AbstractFieldEditor class. When using this method you have to specify methods that return the locations of form definition fragments and form template fragments. If you like you can also specify methods that use stylesheets if you wish to transform the definition before placing it the overall form definition/template. Also you will have to implement a method to load the field value into the form.
The AbstractFieldEditor takes care of the storage, generating form definition/template into correct formats, and generally any other methods the FieldEditor interface expects. Of course it is possible to override these methods with your own implementations. In the JxTemplates that you use to generate the following objects will be at your disposition :

5.17.2.1 Form definition

The form definition shouldn't be too much. Actually this is usually enough. This little blurb of xml will be injected into a fd:group node with id 'field_<fieldTypeId>'.

<?xml version="1.0"?>
<fd:field id="field" xmlns:fd="http://apache.org/cocoon/forms/1.0#definition">  
    <fd:datatype base="string"/>      
</fd:field>

Note that the id of the field is 'field' when using the AbstractFieldEditor keep this id.

5.17.2.2 Form template

This is a little example of a field editor template.

<ft:group xmlns:ft="http://apache.org/cocoon/forms/1.0#template" 
	  id="field_${fieldTypeUse.fieldType.id}" />
  <tr>
    <td>
      <!-- Field type label -->
	My Field
    </td>
    <td>
      <ft:widget id="field"/>
    </td>
  </tr>
</ft:group>

 Here this blurb of XML is not injected into a group a node so you have to define your own. Note that the id of the group is 'field_<fieldTypeId>'. (An important difference from part editors, where your template should not include the ft:group elements.)

 PreviousHomeNext 
5.17 Field editors5.18 Internationalisation