The TreeControl uses predefined images for depicting exploded and closed nodes;
these images can be easily replaced if required. A separate image can be assigned
to every entry within the tree.
One option for this is the use of an ImagMap. The ImageMap is declared outside the tree
in the JSP-Page and assigned to the TreeControl with the attribute "imagemap"
<%@ taglib uri="/WEB-INF/tlds/cc-controls.tld" prefix="ctrl" %>
<%@ taglib uri="/WEB-INF/tlds/cc-utility.tld" prefix="util" %>
<util:imagemap name="imap_products">
<util:imagemapping
rule="prodgroup.open"
src="images/imgBoxOpen.gif"
width="16" height="16"/>
<util:imagemapping
rule="prodgroup.closed"
src="images/imgBoxClosed.gif"
width="16" height="16"/>
<util:imagemapping
rule="product"
src=" images/imgItem.gif"
width="16" height="16"/>
</util:imagemap>
<ctrl:tree
id="prodtree1"
name="products"
action="sample201/productBrowse"
root="true"
linesAtRoot="true"
labelProperty="name"
imageProperty="type"
imagemap="imap_products"
expandMode="multiple"
groupselect="true"
checkboxes="true"/>
Working:
When depicting the tree, the data model returns one expression each via the method getType(), which is compared with the ImageMap. In case of a tally with a rule, the corresponding image is drawn. For closed and exploded nodes, these expressions are automatically extended with the suffix ".open" or ".closed", so that it is possible to use different images for different states. The rules are specified with regular expressions.
The method that returns the expression for the image to be drawn is determined using the attribute "imageProperty". In our example, that type-property is used, which always returns "prodgroup" for groups and "product" for individual leaves.
back |
Layouts
|