Tree servlet 2.0


Simple component lets you display navigation control - tree view. Servlet reads your tree specification from external XML file and renders it in the browser.

Servlet uses Dynatree JQuery plugin.

How to use it:

1) download Dynatree JQuery plugin. Unzip the downloaded file in any directory within your web application. Path to this directory you will describe in servlet's configuration file.

2) download treePackage.jar and save it in WEB-INF/lib

3) describe TreeServlet in web.xml file
 


    <servlet>
     <servlet-name>TreeServlet</servlet-name>
     <servlet-class>com.jsos.tree.TreeServlet</servlet-class>
    </servlet>

4) define a mapping:
 


    <servlet-mapping>
     <servlet-name>TreeServlet</servlet-name>
     <url-pattern>/servlet/TreeServlet</url-pattern>
    </servlet-mapping>

you can pass the following parameters for this servlet:

path - describes a path for your resource
type - Optional parameter. Describes a content type for your resource.
expires - Optional parameter. Describes a caching time (in seconds) for the extracted resource.

And now for the usage you have to pass your XML file with tree description (configuration) to this servlet: http://your_host/servlet/TreeServlet?your_config_file. For example, you can use servlet as a source of some frame (iframe) with navigation control: <iframe src="http://your_host/servlet/TreeServlet?your_config_file"> </iframe> etc.

alternatively, you can pass this configuration file as an initial parameter for this servlet. Parameter's name is config:
 


    <servlet>
    <servlet-name>TreeServlet</servlet-name>
    <servlet-class>com.jsos.tree.TreeServlet</servlet-class>
    <init-param>
    <param-name>config</param-name>
    <param-value>your_config_file</param-value>
    </init-param>
    </servlet>

Configuration file:

It is an XML file.

root node (you can use any name here) has got the following attributes:

style - optional attribute, describes CSS style for the whole control
treeStyle - optional attribute, describes CSS style for the tree itself
title - optional attribute, describes a title for the whole control
plugin - optional attribute, describes a path to dynatree JQuery plugin

the tree itself could be described as a collection of nodes (probably nested). Tag node supports the following attributes:

title - describes a title for node
url - describes an url for node
target - optional attribute, describes a target frame for node's link

E.g.:
 


    <root style="border:none;background:#FFFFF0">
    <node title="Coldbeans">
     <node title="JSOS" url="http://servletsuite.com/servlets.htm"> </node>
     <node title="Coldtags" url="http://servletsuite.com/jsp.htm"> </node>
    </node>
    <node title="Mashups">
     <node title="Photo Map" url="http://photomap.linkstore.ru"> </node>
    </node>
    </root>

and you will get some like this:

For JSP see also Tree taglib in Coldtags suite

For downloading:

servlet: treePackage.jar  
 

 © Coldbeans    Comments?
 

See also JSOS - the largest collection of servlets and filters.

Also in JSOS: