Navigation Tree  Locate

Navigating between pages in the Business Service Console can be done using the navigation tree located at the left side of the console. This section explains how to build such a navigation tree, how to populate it and how to attach pages to tree nodes.

The navigation tree area itself is a component which is shared among a number of pages that display the content of the tree nodes. The tree component is embedded into JSP pages using the <syswf:component> JSP tag. The component itself contains a simple JavaScript that creates a JSTreeMenu and populates it.

To learn how to create a new web UI component, see Web Framework.

For detailed information about the JSTree menu and its implementation, see the scripts/tree.js script. For examples of existing trees in the Business Service Console to learn from, refer to browse/tree.jsp and publish/tree.jsp

Creating the Tree Component  Locate

The tree component used in the Business Service Console contains some small graphics, so the tree itself is embedded in a table. Please use the snippet in Example 25 as a boilerplate for your tree:

Example 25. Tree Component Source

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="syswf" uri="http://systinet.com/jsp/syswf" %>

<!-- The table, that laids out the tree and graphics -->
<table name="myMenu" id="myMenu" border="0"><tr>
    <td><img src="gfx/0.gif" alt="" width="1" height="400" border="0"></td>
    <td valign="top">

    <!-- The div that identifies the scrollable portion of the pane -->
    <div id="divCont" name="divCont" onScroll="saveScrollInfo('tree',this,'tree');">

    <!-- This area is identified as a tree to other scripts and components -->
    <div id="tree" name="tree"/>
    <script>
        <!-- Tree declaration. Use names for variables, that suit to your needs -->
        var treeRoot = new JSTreeMenu("root",
            "Root",
            "<syswf:control targetTask="/root" 
             targetDepth="${sessionStack.currentDepth - 1}" mode="script" />",
            "root.gif",
            "root.gif",
            "");

        <!-- Here go the individual nodes of the tree -->

        <!-- This is the finalization of the tree, refocusing the 
        element that corresponds  to the displayed page -->
        redrawTree();
        <c:if test="${not empty focus}">
            publish.focus("<c:out value="${focus}"/>");
        </c:if>
    </script>
    </div>
    </div>
    </td></tr>
</table>
[Note]Note

The tree is enclosed in the <div> tags. The framework JavaScripts look for its IDs and identify areas that are scrollable or contain the tree. Please do not alter this pattern and the values of the IDs when creating your trees or the framework will not recognize your component properly.

The parameters for the JSTreeMenu constructor are:

            new JSTreeMenu(id, caption, onClickAction [, collapsedImage [, expandedImage ] ] )

Table 91.  JSTreeMenu Parameters

ParamDescriptionRequired
idAn identifier for the tree. Yes
captionThe caption text to be displayed Yes
onClickActionThe code which will be executed when the tree node is selected by the user Yes
collapsedImageThe image of the node in its collapsed state. The filename is relative to the gfx/tree directory. No
expandedImageThe image of the node in its expanded state. The filename is relative to the gfx/tree directory. No

Adding Items to the Tree  Locate

Add individual items that should be displayed in the tree as separate JSTreeMenuItem controls and link them to the desired parent. You can attach JavaScript code for each of the items. In most cases the action will simply go over to the task represented by the item in the navigation tree.

Start by creating a new tree item like this:

var subitem = new JSTreeMenuItem(
    "subitem1",
    "SubItem 1",
    "&lt;syswf:control targetTask="/root/someTask" 
       targetDepth="${sessionStack.currentDepth - 1}" 
       mode="script" /&gt;",
    "provider.gif",
    "provider.gif",
    "")

The parameters for the JSTreeMenuItem constructor are:

new JSTreeMenuItem(id, caption, onClickAction [, collapsedImage [, expandedImage ] ] )
            

Table 92.  JSTreeMenuItem Parameters

ParamDescriptionRequired
idAn identifier for the treeYes
captionThe caption text to be displayedYes
onClickActionThe code which will be executed when the tree node is selected by the userYes
collapsedImageThe image of the node in its collapsed state. The filename is relative to the gfx/tree directory. No
expandedImageThe image of the node in its expanded state, this filename is relative to the gfx/tree directory. No

Each control should have an unique id as the first parameter.

If you want the Business Service Console to open a new page, use the standard way to go to a given task:

<syswf:control targetTask="/browse" targetDepth="${sessionStack.currentDepth - 1}" mode="script" />

Note the sessionStack.currentDepth assignment. It causes the new task to replace the current one in the task history bar in the page header.

Then you need to add the newly created item to its parent node. In this example, we add the item underneath the root node:

treeRoot.add(subitem);

Managing Focus  Locate

When the task is entered as a result of clicking on a tree node, the whole page is reloaded, including the tree itself. Because the tree is reconstructed as well, you need to have code in the displayed task's JSP that passes the id of the tree node that is going to be focused. Usually this id is the id of the Tree node that launched the page's task. Use the focus parameter to pass the id into the tree Web UI component as shown in Example 26:

Example 26. How to Set a Focused Node on the Tree

<!-- The tree area will be made resizable, by wrapping it between appropriate header
     and footer
-->
<syswf:wrap headerTemplate="design/resizableFrameHeader.jsp" 
   footerTemplate="design/resizableFrameFooter.jsp" >
    <!-- Includes the browse tree into the page, place your tree 
     component ID into the "name" attribute -->
    <syswf:component name="browseTree" prefix="browseTree">
        <!-- Substitute your node's ID for the value -->
        <syswf:param name="focus" value="subitem1"/>
    </syswf:component>
</syswf:wrap>

Using a Resizable Tree  Locate

To make it possible to adjust the width of the navigation tree, simply wrap the tree between resizableFrameHeader and resizableFrameFooter tags:

Example 27. Making a Tree Resizable

<!-- The tree area will be made resizable, by wrapping it between appropriate header
     and footer
-->
<syswf:wrap headerTemplate="design/resizableFrameHeader.jsp" 
   footerTemplate="design/resizableFrameFooter.jsp" >
    <!-- Includes the browse tree into the page, place your tree 
     component ID into the "name" attribute -->
    <syswf:component name="browseTree" prefix="browseTree">
        <!-- Substitute your node's ID for the value -->
        <syswf:param name="focus" value="subitem1"/>
    </syswf:component>
</syswf:wrap>