Wikibooksβ

XForms/Outline Editor

Contents

Sometimes you want to allow a user to be able to add properties to a list that change the appearance of the item in the list. In this example, the level of indentation is controlled by an attribute in a list called the "level" which is the indentation level in an outline view.

Note: This program was based on an example Kurt Cagle posted on the Mozilla XForms developer news group. This example posted with his permission.

Here is a sample outline-editor program. If you want to test this, be sure to use the edit view to copy the text. This file includes several tab characters that do not display correctly in the view mode.

The structure of this program uses custom events. Note that in the model there are a series of actions, each with their own event name:

<xf:modelid="data_model">
...
<xf:actionev:event="addItemEvent">
...

These events are called directly inside of a trigger like this:

<xf:dispatchname="addItemEvent"target="data_model"/>

Note that the target attribute is the name of the model that the events are located.

Although actions can be tucked directly into a trigger, sometimes action are more logically grouped with instance data and should be placed directly in the model. This also allows other events need to reuse these actions, so it is a good ideal to put reuseable actions directly in a model