Tree Applet documentation v. 2.6
Copyright SCAND LLC 2005

Initialization

Tree applet can load content in two modes:

In both cases it is possible to manage items of the tree applet using public methods of it. This can be done as from another Java applet that uses Tree applet, so from browser using JavaScript. The public methods are described below in the section "Tree methods".

Items parameters

To populate tree with data you should specify for every item set of required parameters, listed below.

Name Required Possible values Description
ITEMi Yes according to IDC parameter Item's identifier. Used as reference to item while accessing from script functions.
TEXTi Yes Any string value Visible name of tree item, which will be displayed on screen.
ACTIONi Yes Valid parameters for script function List of parameters, transmitted to script function, described by EVAL parameter.
Can accept:
1. Integer value
2. String value in single or double quotation marks.
3. Collection of (1) and (2), separated by commas.
LEVELi Yes Integer Level of current node. Must be from 0 till previous item's level + 1.
SELECTi No Any value If specified, then current item will be selected.(Cursor will be placed on last selected item.)
IM0i, IM1i No Integer Indexes of images (given by IMAGEi parameters), associated with current item. Ignored if no ICONS_PERMANENT parameter specified.

It is possible to specify a file name directly in this parameter. In this case the parameter should have value in format f<file_name>

CHILDi No Any value Use in dynamical tree only. Not null value means non-terminal node - children for it will be loaded from server. (See also Dynamic loading section)
COLORi No HTML color format The color of item's text
SELCOLORi No HTML color format The color of text for selected items
OPENEDi No Any value Sets item initially to open state
CHECKEDi No Any value If specified, then current item will be checked (See Check items section)
CHECK_DISABLEDi No Any value If specified, then current item will have disabled checkbox (See Check items section)
UNDERLINEi No Any value If specified, then current item will be underlined.
FONTi No Java font format The font of item's text in format <font_name>-<font_style>-<font_size>
USERDATAi No Values in format <key>='<value>' User-defined data for node
 Note: 'i' indicates the sequential number of an item in initialization list. Starts from 0.

 Example 1. Possible item definition.

<PARAM NANE='ITEM0' VALUE='0'>
<PARAM NANE='NAME0' VALUE='Root item'>
<PARAM NANE='ACTION0' VALUE="'r13'">
<PARAM NANE='LEVEL0' VALUE='0'>
<PARAM NANE='SELECT0' VALUE='1'>

Representation parameters

This set of parameters describes the color, fonts and other attributes of tree applet. Attributes of fonts and attributes can be redefined for each tree item using Items parameters and Items Properties Control.

Color parameters

This set of parameters describes the color model of the tree applet.
Name Description
BG_COLOR Background color.
FG_COLOR Color of non-selected item's label.
BGSEL_COLOR Background of selected item.
FGSEL_COLOR Color of selected item's label.
LINES_COLOR Color of lines in tree
CROSSES_COLOR Color of crosses for non-terminal items
CONTOUR_COLOR Color of selected items' contour color
 

Size parameters

This set of parameters describes sizes of tree components:

 o NODE_HEIGHT

The height of node. All nodes in tree has the same height. Default value is 18.

 o IMAGE_WIDTH / IMAGE_HEIGHT

Size of icons in tree. If real size of any image differs from this value, image will be resized. Default value is 16x16.

 o LEVEL_INDENT

Indent between two levels in tree. Default value is 4.

 o MARGIN_LEFT / MARGIN_TOP / MARGIN_RIGHT / MARGIN_BOTTOM

Define margin values from left/top/right/bottom borders correspondingly.

Images control

This set of parameters specifies the image list of tree items and behavior of showing images.

 o IMAGEi

Specifies the list of images for the tree items. Has structure IMAGE0, IMAGE1, ... ,IMAGEn. This numbers can be passed in IM0 and IM1 parameters of an item (see Items parameters).

If ICONS_PERMANENT parameter is not specified, they will have next meaning:
IMAGE0 - Image for root nodes.
IMAGE1 - Image for terminal nodes.
IMAGE2 - Image for non-terminal opened nodes.
IMAGE3 - Image for non-terminal closed nodes.

The path for image starts from TreeApplet class folder.

 o BACKGROUND_IMAGE

Specifies image name for background of the applet

 o BACKGROUND_IMAGE_POSITION

Sets position of background image in format <x>;<y>. If not specified, background image will be repeated in the background.


 o ICONS_PERMANENT

If this parameter has non-empty value, then images associated with the item should be given in IM0,IM1 parameters, otherwise, default images from IMAGE0...IMAGE3 parameters will be used instead.

Important: If this parameter specified, minimum one of images (IM0 or IM1) must be specified for each node. Otherwise the tree will not be initialized.

 o CROSSES

If this parameter has non-empty value, non-terminal items will be marked with "+" on the left side

 o ROOT_CROSS

If this parameter has 0 value, root items displayed without "+" expand symbol

 o FONT

Font of tree applet in Java font format: <font_name>-<font_style>-<font_size>

Default value is "Verdana", size 13, style PLAIN.

 o ROOT_CLOSEABLE

Allows you to collapse root nodes with LEVEL=0. Disabled by default. 

Check items

 This set of parameters permits to use checkboxes as items in tree

 o CHECKBOXES

Creates tree with checkboxes for all nodes. Images for checkboxes has fixed size 11x11 pt and can be specified with followed parameters:

Checkboxes representation:

Name Description Default value
IMAGE_CHECKED Image for checked item icons/item_checked.gif
IMAGE_UNCHECKED Image for unchecked item icons/item_unchecked.gif
IMAGE_SHADEN Image for unchecked item, who has checked children on next levels icons/item_shaden.gif

 o SHOW_IMAGES

Shows checkboxes with images. Default value is "1".

 o CHECK_SIZE

Size of images for checked/unchecked items. Default value is 11x11 ps..

 o AutoCheckBoxes

Processing of checks is automatic - if item checked, all subnodes becomes to checked state too and all parents came into shadow mode. Default value is "1".

Dynamic loading

In case of huge set of data reasonable to load only root nodes from HTML page and load additionally subnodes as required. For this possibility parameter GET_DOC is using.

Important: This possibility available only in full version of jtree.

 o GET_DOC

Used in dynamical trees. It means the name of document, which will load the data from server. Loading happens when:
    1. This parameter is not null,
    2. Node hasn't child subnodes
    3. Parameter CHILD for this node is not null.
The document can get identifier of called node through id parameter and must return the list of strings, ended by empty string. Every string contains information about single child node in the next format:
    "Name","id","action",hasChildren,im0,im1,UNDERLINE
Where id - identifier of the node, name - its name, action - the same meaning as ACTION parameter, hasChildren - CHILD parameter, im0,im1 - IM0,IM1 parameters. If UNDERLINE world specified in last position item will be underlined.

Example 2. ASP document for loading subnodes from database.

<%
id = request("id")
sqlStr ="select KeyField, NameField from DataTable where ParentKeyFied=" & id
set ResultSet = DBConnection.execute(sqlStr)
while not ResultSet.eof
          Key = ResultSet("KeyField")
          Name = ResultSet("NameField")
          response.writeln("""" & Name & """,""" & Key & """,""" & Key & """,0,1,2" )
          ResultSet.moveNext
wend
response.writeln("")
%>

If name of document starts with javascript: prefix, information will be loaded from javascript function, the name of wich should follow specified prefix.

Example 3. Declaration of JavaScript initialization function

<html>
<head>
<script>
function getDoc()
{
return "'Root Node','Root Node',\"'Root Node'\",0,1,2"
}
</script>
</head>
<body>
...
<applet>
<param name="GET_DOC" value="getDoc">
</applet>
...
</body>
</html>

 o INIT_DOC

The name of document for initial loading of tree. (See GET_DOC parameter) 

 Menu parameters

 o MENU

Enabling menu in tree applet. It will be called a