Tree Applet documentation v.
2.6
Copyright SCAND LLC 2005
Tree applet can load content in two modes:
initialize it from PARAM tags, present in HTML that contain the applet (these tags are descirbed below in section "Tree parameters")
load items located on sub-levels dynamically from the server where the applet is loaded from
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".
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 |
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'>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.
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 |
This set of parameters describes sizes of tree components:
The height of node. All nodes in tree has the same height. Default value is 18.
Size of icons in tree. If real size of any image differs from this value, image will be resized. Default value is 16x16.
Indent between two levels in tree. Default value is 4.
MARGIN_LEFT / MARGIN_TOP / MARGIN_RIGHT / MARGIN_BOTTOM
Define margin values from left/top/right/bottom borders correspondingly.
This set of parameters specifies the image list of tree items and behavior of showing images.
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).Specifies image name for background of the applet
Sets position of background image in format <x>;<y>. If not specified, background image will be repeated in the background.
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.
If this parameter has non-empty value, non-terminal items will be marked with "+" on the left side
If this parameter has 0 value, root items displayed without "+" expand symbol
Font of tree applet in Java font format: <font_name>-<font_style>-<font_size>
Default value is "Verdana", size 13, style PLAIN.
Allows you to collapse root nodes with LEVEL=0. Disabled by default.
This set of parameters permits to use checkboxes as items in tree
Creates tree with checkboxes for all nodes. Images for checkboxes has fixed size 11x11 pt and can be specified with followed parameters:
| 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 |
Shows checkboxes with images. Default value is "1".
Size of images for checked/unchecked items. Default value is 11x11 ps..
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 loadingIn 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.
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.
<%
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>
The name of document for initial loading of tree. (See GET_DOC parameter)
Enabling menu in tree applet. It will be called a