DATABASE DRIVEN TREE MENU
hey i've downloaded tigra_jsp_database.zip
i'm not getting how to replace TREE_ITEMS.js with SoftcomplexTreeBuilder.java.
here is my file index.jsp
<%@ page import="java.lang.*, java.util.*, java.io.*, java.sql.*, tigra.*" %>
<%!
String dbUser = "cipay";
String dbPassword = "cipay";
String dbPath = "tciserver";
//Database control panel URL: http://www.freesql.org/phpMyAdmin-2.2.0/index.php
Connection conn = null;
String treeName = "TREE_ITEMS";
String treeClassName = "cbv";
String treeDataTableName = "Menu";
Integer treeKeyRootValue = 0;
String treeKeyFieldName = "UniqueId";
String treeParentIdFieldName = "ParentId";
String treeValueFieldName = "Caption";
String treeJavaScriptCode = "";
%>
<%
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch ( ClassNotFoundException e) {
out.println(" Error Class : " + e);
}
try{
Connection conn = SimpleConnectionProvider.getTCIConnection(dbPath, dbUser, dbPassword);
SoftcomplexTreeBuilder treeBuilder = new SoftcomplexTreeBuilder();
treeJavaScriptCode = treeBuilder.build(treeName, treeClassName , conn, treeDataTableName, treeKeyRootValue, treeKeyFieldName, treeParentIdFieldName,
treeValueFieldName);
} catch (Exception e) {
out.println("ERROR: " + e);
}
%>
<html>
<head>
<link rel="stylesheet" type="text/css" title="standard Style" href="static/styles/cashin.css">
</head>
</html>
<html>
<body onload="expand_all('hcomp_tree', true);"style="background-color:RGB(49, 60, 76);font-family:
Tahoma,Arial;font-size:11px;padding:0px;color: #000000;background:#31659C;cursor='hand';width: 100%;border:1px
solid;filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#ffffffff',EndColorStr='#ADBECE')">
<script language="JavaScript" src="tree.js"></script>
<script language="JavaScript" name="tree_items"><%=treeJavaScriptCode%>
</script>
<script language="JavaScript" src="tree_tpl.js"></script>
<input type='hidden' id='tciReportUser' name='tciReportuser' value=''/>
<table class="reportBody" cellpadding="5" cellspacing="0" cellpadding="10" border="0" width="100%">
<tr>
<td>
<p><a href="#" onclick="expand_all('hcomp_tree');">Open</a> | <a href="#" onclick="expand_all('hcomp_tree',
true);">Collapse</a></p>
<script language="JavaScript">
hcomp_tree = new tree (TREE_ITEMS, TREE_TPL);
</script>
</td>
</tr>
</table>
</body>
</html>
and SoftcomplexTreeBuilder.java is as under
package tigra;
import java.lang.*;
import java.util.*;
import java.io.*;
import java.sql.*;
public class SoftcomplexTreeBuilder extends Object{
public String build (String treeName, String className, Connection conn, String dataTableName, int rootValue, String keyFieldName, String
parentIdFieldName, String valueFieldName) throws Exception
{
String s = getNodes (className, conn, dataTableName, rootValue, keyFieldName, parentIdFieldName, valueFieldName);
return "var " + treeName + " = [" + (s == "" ? "[]" : s) + "];\r";
}
String getNodes (String className, Connection conn, String dataTableName, int rootValue, String keyFieldName, String parentIdFieldName, String
valueFieldName) throws SQLException
{
String code = "";
Statement stat = conn.createStatement();
try
{
ResultSet rs = stat.executeQuery("SELECT " + keyFieldName + ", " + valueFieldName + " FROM " + dataTableName + " WHERE " +
parentIdFieldName + " = " + Integer.toString(rootValue));
try
{
while (rs.next())
{
code += (code != "") ? ",\r\t" : "";
code += "['" + rs.getString(valueFieldName) + "', 0, {'" + className + "':" + rs.getObject(keyFieldName) + "}";
String s = getNodes(className, conn, dataTableName, rs.getInt(keyFieldName), keyFieldName, parentIdFieldName, valueFieldName);
code += (s == "") ? "]" : ", \r\t" + s + "]";
}
}
finally
{
rs.close();
}
}
finally
{
stat.close();
}
return code;
}
}
now i want to change my Tree_item.js
var userCode=window.parent.tciReportUser;
var TREE_ITEMS =
[
['Masters', 0,
['User Categories','WorkArea.action?typeId=1200&maker_checker=Maker&masterLevel= > Master > User Categories@Category List'],
['Application Users','WorkArea.action?typeId=1150&maker_checker=Maker&masterLevel= > Master > Application Users@User List'],
['User - Client Relation','AddTCWMaster.action?typeId=1450&maker_checker=Maker&masterLevel= > Master > User - Client Relations@User- Client Relation Entry'],
['My Products','WorkArea.action?typeId=1100&maker_checker=Maker&masterLevel= > Master > My Products@My Products Entry'],
['Product A/c','AddTCWMaster.action?typeId=1350&maker_checker=Maker&masterLevel= > Master > Product Accounts@Product AccountsEntry'],
['User Product','AddTCWMaster.action?typeId=1250&maker_checker=Maker&masterLevel= > Master > User Product@User Product Entry'],
['User Account','AddTCWMaster.action?typeId=1300&maker_checker=Maker&masterLevel= > Master > User Account@User Accounts'],
['Beneficiaries','WorkArea.action?typeId=1825&maker_checker=Maker&masterLevel= > Master > Beneficiaries@Beneficiaries Entry'],
['Drawers','WorkArea.action?typeId=1875&maker_checker=Maker&masterLevel= > Master > Drawers@Adhoc/Registered Drawer Entry'],
['Authorization Matrix','underconstruction.html'],
['Account Name','WorkArea.action?typeId=1000&maker_checker=Maker&masterLevel= > Master > Account Name@Account Name'],
],
['Masters Auth', 0,
['User Categories','CheckerAction.action?typeId=1200&maker_checker=Checker&masterLevel= > Master Auth. > User Categories@CategoryAuthorization'],
['Application Users','CheckerAction.action?typeId=1150&maker_checker=Checker&masterLevel= > Master Auth. > Application Users@UserAuthorization'],
['User - Client Relation','CheckerAction.action?typeId=1450&maker_checker=Checker&masterLevel= > Master Auth. > User - ClientRelations@User Client Relation Authorization'],
['My Products','CheckerAction.action?typeId=1100&maker_checker=Checker&masterLevel= > Master Auth. > My Products@My ProductsAuthorization'],
['Product A/c','CheckerAction.action?typeId=1350&maker_checker=Checker&masterLevel= > Master Auth. > Product Accounts@ProductAccount Authorization'],
['User Product','CheckerAction.action?typeId=1250&maker_checker=Checker&masterLevel= > Master Auth. > User Product@User ProductAuthorization'],
['User Account','CheckerAction.action?typeId=1300&maker_checker=Checker&masterLevel= > Master Auth. > User Accounts@User AccountAuthorization'],
['Beneficiaries','CheckerAction.action?typeId=1825&maker_checker=Checker&masterLevel= > Master Auth. > Beneficiaries@BeneficiariesAuthorization'],
['Drawers','CheckerAction.action?typeId=1875&maker_checker=Checker&masterLevel= > Master Auth.> Drawers@Adhoc/Registered DrawerEntry'],
['Authorization Matrix','underconstruction.html'],
['Account Name','CheckerAction.action?typeId=1000&maker_checker=Checker&masterLevel= > Master Auth. > Account Name@Account NameAuthorization'],
],
['Tools',0,
['Clear User','ClearUserClient.jsp'],
['Reset User','ResetUserClient.jsp'],
['Change Password','ChangePWD.action?typeId=5050'],
['Switch Client','getSwitchClient.action'],
]
];
what r the changes i need to do
how can i call SOFTComplextreebuilder instead of items.js
|