## WebFXLoadTree

This object type is used to create the actual tree root and can be used to populate the tree with tree items loaded from an xml file.

The `WebFXLoadTree` extends `WebFXTree` (see the xTree API) so all properties and methods provided by `WebFXTree` are available.

### Constructor

    new WebFXLoadTree(sText, sXmlSrc, sAction, sBehavior, sIcon, sOpenIcon)

Name | Description
sText | The text label for the tree root.
sXmlSrc | The source for the xml file to load when expanded.
sAction | Optional. The action (uri) associated with the tree root.
sBehavior | Optional. The behavior of the tree. Valid values are `"classic"` and `"explorer"`. When the value is set to `"explorer"` the default icon for an empty item is the same as the folder icon.
sIcon | Optional. The icon image to use for this item. In case this item is a folder this will be used when the folder is closed.
sOpenIcon | Optional. The icon image to use for this item when it is opened. This is only used for folder items that are opened/expanded.

### Properties

Name | Description
All properties from `WebFXTree`.
src | The source to the xml file that decribes the sub trees. Notice that this is read-only after the xml file has started to load so any changes done to the source are only valid before the loading of the first file.
loading | Read only. A boolean flag which is true if the xml file has started loading and not yet finished.
loaded | Read only. A boolean flag which is true if the xml file has been loaded.
errorText | Read only String. If the loading for any reason failed the reason can be found in the `errorText` property. If no error occured this is `""` (an empty string).

### Methods

Name | Description
reload() | Reloads the XML file from the server and recreates the children of this node.
All methods from `WebFXTree`.

## WebFXLoadTreeItem

This object type is used to create tree items that can be added to the tree root, or to other tree items to create sub folders in the tree. When an `WebFXLoadTreeItem` is expanded an xml file is loaded that is then used to populate the item with child items.

The `WebFXLoadTreeItem` extends `WebFXTreeItem` (see the xTree API) so all properties and methods provided by `WebFXTreeItem` are available.

### Constructor

    new WebFXLoadTreeItem(sText, sXmlSrc, sAction, eParent, sIcon, sOpenIcon)

Name | Description
sText | The text label for the tree item.
sXmlSrc | The source for the xml file to load when expanded.
sAction | Optional. The action (uri) associated with the tree item.
eParent | Optional. The parent `WebFXTreeItem` or `WebFXTree` that the item should be added to.
sIcon | Optional. The icon image to use for this item. In case this item is a folder this will be used when the folder is closed.
sOpenIcon | Optional. The icon image to use for this item when it is opened. This is only used for folder items that are opened/expanded.

### Properties

Name | Description
All properties from `WebFXTreeItem`.
src | The source to the xml file that decribes the sub trees. Notice that this is read-only after the xml file has started to load so any changes done to the source are only valid before the loading of the first file.
loading | Read only. A boolean flag which is true if the xml file has started loading and not yet finished.
loaded | Read only. A boolean flag which is true if the xml file has been loaded.
errorText | Read only String. If the loading for any reason failed the reason can be found in the `errorText` property. If no error occured this is `""` (an empty string).

### Methods

Name | Description
reload() | Reloads the XML file from the server and recreates the children of this node.
All methods from `WebFXTree`.

## The xml format

The only valid element in the xml file is the `tree` item. A `tree` item can contain zero, one or more `tree` items.

### Attributes

There are five valid attributes that you can provide on a `tree` item.

Name | Description
text | Required. The text label for the tree item.
xmlSrc | Optional. The source for the xml file to load when expanded.
action | Optional. The action (uri) associated with the tree item.
icon | Optional. The icon image to use for this item. In case this item is a folder this will be used when the folder is closed.
openIcon | Optional. The icon image to use for this item when it is opened. This is only used for folder items that are opened/expanded.

### DTD

The xml file does not have to be valid to work (only well formed) but if you want to ensure that you didn't do anything wrong you can use the following document type definition:

    <!ELEMENT tree (tree*)>
    <!ATTLIST tree
              text      CDATA   #REQUIRED
              src       CDATA   #IMPLIED
              action    CDATA   #IMPLIED
              icon      CDATA   #IMPLIED
              openIcon  CDATA   #IMPLIED>

To use the dtd in your xml file add a `DOCTYPE` to the head of your xml file. Below is tree.dtd.xml shown. This represents the same xml tree as in tree.xml with a `DOCTYPE` declaration.

    <?xml version="1.0"?>

    <!DOCTYPE tree SYSTEM "tree.dtd">
    <tree>
    	<tree text="Loaded Item 1" action="href://webfx.eae.net" />
    	<tree text="Loaded Item 2">
    		<tree text="Loaded Item 2.1" action="javascript:alert(2.1)" />
    	</tree>
    	<tree text="Load &quot;tree1.xml&quot;" src="tree1.xml" />
    </tree>

Introduction
Usage
API
Implementation
Demo
Download

Author: Erik Arvidsson