Java-JSP Interface for HierMenus (4/4)
[previous] |
A Java-JSP Menu Builder for HierMenus
Replace the Hierarchical Menu HM_Arrays.js
The HierMenus JavaScript file HM_Loader.js
has default parameters that
set up the look and feel of the menu. This file internally loads HM_Arrays.js
and the Netscape and IE specific JavaScript files needed to drive the menu. To replace
the HM_Arrays.js
, you have to follow these steps:
|
Your final directory structure should look like this
{webapp_directory}\menu-app\menu.jsp
{webapp_directory}\menu-app\js\HM_Loader.js
{webapp_directory}\menu-app\js\ HM_ScriptNS4.js
{webapp_directory}\menu-app\js\ HM_ScriptIE4.js
{webapp_directory}\menu-app\js\ HM_ScriptDOM.js
{webapp_directory}\menu-app\WEB-INF\classes\HMContentTree.class
{webapp_directory}\menu-app\WEB-INF\classes\ HMContentTreeRoot.class
{webapp_directory}\menu-app\WEB-INF\classes\ HMContentTreeItem.class
{webapp_directory}\menu-app\WEB-INF\classes\ MenuContentBuilder.class
If you are using tomcat, webapp_directory
is tomcat's webapps directory,
and menu-app
is the Web application directory containing JSP, HTML,
JavaScript and class files.
Below is the listing for a menu JSP that adds the dynamic generation of the menu contents
and substitutes the static HM_Arrays.js
.
<%@ page language="java" buffer="32kb"%>
<%
//MenuContentBuilder is the java class that builds the menu tree content
HMContentTree menuContentTree = MenuContentBuilder.getTree("Paulo");
String menuContent = menuContentTree. toHMContent();
%>
<html>
<head>
<script language="javascript">
<% out.write(menuContent); %>
</script>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
if(window.event + "" == "undefined") event = null;
function HM_f_PopUp(){return false;};
function HM_f_PopDown(){return false};
popUp = HM_f_PopUp;
popDown = HM_f_PopDown;
HM_a_TreesToBuild = [1];
//-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.2" SRC="js/HM_Loader.js" TYPE='text/javascript'></SCRIPT>
</head>
<body>
<a href="#"
onClick="return false;"
onMouseOver = "popUp('HM_Menu1',event)"
onMouseOut = "popDown('HM_Menu1')"><b>Please bring your mouse over here</b></a>>
<IMG src="tri.gif" width=7>
</body>
</html>
In the listed JSP code, the generation of the menu contents in the proper format happens in two places:
|
Conclusion
This article provides you with listings for HMContentTree
,
HMContentTreeRoot
, HMContentTreeItem
and a sample
MenuContentBuilder
class. It also presents menu.jsp
, which
brings the content dynamism obtained through these Java classes into the existing
HierMenus JavaScript files.
About the authors
Paulo Caroli, www.caroli.org, MSc in Software Engineer, is a Senior Java Developer with more than 8 years of experience in Application Development. He is an expert in Object Oriented techniques and has been using J2EE in Web Applications for the past 4 years. He currently works for OmniPros (www.omnipros.com).
Srimant Misra is a Senior Consultant with 6 years of experience in Information Technology. He's an expert in OOAD and performance monitoring of J2EE applications. He currently works for eTouch Systems (www.etouch.net).
[previous] |
Created: November 13, 2002
Revised: November 13, 2002
URL: https://webreference.com/programming/java/jspmenus/4.html