Board Logo

tree from database (oracle)
nashenvy - 11/8/2006 at 02:25 AM

i wanna create tree dynamically from database
what are changes i need to do
code


tigra - 11/8/2006 at 02:39 PM

You don't need any changes in the menu script. Just generate the text of the items structure with your server side script. There are plenty of samples for different languages in tree menu and drop down menu forums.


nashenvy - 11/30/2006 at 10:59 PM

Quote:
thanks for replying

can u help with providing any link or showing the code to generate tree menu from database. And i need to operate it on Mozilla Firefox and IE.
Its hard to find any example related my subject.

Thanking u in advanace


You don't need any changes in the menu script. Just generate the text of the items structure with your server side script. There are plenty of samples for different languages in tree menu and drop down menu forums.


tigra - 12/1/2006 at 08:47 AM

This topic is discussed at: http://www.softcomplex.com/forum/viewthread_230/
Also there is a bunch of server side samples in the drop down menu forum (items data format is interchangeable):
http://www.softcomplex.com/forum/forumdisplay_29/


nashenvy - 12/4/2006 at 12:59 AM

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 != "") ? ",rt" : "";
code += "['" + rs.getString(valueFieldName) + "', 0, {'" + className + "':" + rs.getObject(keyFieldName) + "}";

String s = getNodes(className, conn, dataTableName, rs.getInt(keyFieldName), keyFieldName, parentIdFieldName, valueFieldName);

code += (s == "") ? "]" : ", rt" + 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 [email protected] List'],
['Application Users','WorkArea.action?typeId=1150&maker_checker=Maker&masterLevel= > Master > Application [email protected] List'],
['User - Client Relation','AddTCWMaster.action?typeId=1450&maker_checker=Maker&masterLevel= > Master > User - Client [email protected] Client Relation Entry'],
['My Products','WorkArea.action?typeId=1100&maker_checker=Maker&masterLevel= > Master > My [email protected] Products Entry'],
['Product A/c','AddTCWMaster.action?typeId=1350&maker_checker=Maker&masterLevel= > Master > Product [email protected] AccountsEntry'],
['User Product','AddTCWMaster.action?typeId=1250&maker_checker=Maker&masterLevel= > Master > User [email protected] Product Entry'],
['User Account','AddTCWMaster.action?typeId=1300&maker_checker=Maker&masterLevel= > Master > User [email protected] Accounts'],
['Beneficiaries','WorkArea.action?typeId=1825&maker_checker=Maker&masterLevel= > Master > [email protected] Entry'],
['Drawers','WorkArea.action?typeId=1875&maker_checker=Maker&masterLevel= > Master > [email protected]/Registered Drawer Entry'],
['Authorization Matrix','underconstruction.html'],
['Account Name','WorkArea.action?typeId=1000&maker_checker=Maker&masterLevel= > Master > Account [email protected] Name'],

],
['Masters Auth', 0,
['User Categories','CheckerAction.action?typeId=1200&maker_checker=Checker&masterLevel= > Master Auth. > User [email protected]'],
['Application Users','CheckerAction.action?typeId=1150&maker_checker=Checker&masterLevel= > Master Auth. > Application [email protected]'],
['User - Client Relation','CheckerAction.action?typeId=1450&maker_checker=Checker&masterLevel= > Master Auth. > User - [email protected] Client Relation Authorization'],
['My Products','CheckerAction.action?typeId=1100&maker_checker=Checker&masterLevel= > Master Auth. > My [email protected] ProductsAuthorization'],
['Product A/c','CheckerAction.action?typeId=1350&maker_checker=Checker&masterLevel= > Master Auth. > Product [email protected] Authorization'],
['User Product','CheckerAction.action?typeId=1250&maker_checker=Checker&masterLevel= > Master Auth. > User [email protected] ProductAuthorization'],
['User Account','CheckerAction.action?typeId=1300&maker_checker=Checker&masterLevel= > Master Auth. > User [email protected] AccountAuthorization'],
['Beneficiaries','CheckerAction.action?typeId=1825&maker_checker=Checker&masterLevel= > Master Auth. > [email protected]'],
['Drawers','CheckerAction.action?typeId=1875&maker_checker=Checker&masterLevel= > Master Auth.> [email protected]/Registered DrawerEntry'],
['Authorization Matrix','underconstruction.html'],
['Account Name','CheckerAction.action?typeId=1000&maker_checker=Checker&masterLevel= > Master Auth. > Account [email protected] 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


nashenvy - 12/4/2006 at 06:27 AM

Quote:
Originally posted by tigra
This topic is discussed at: http://www.softcomplex.com/forum/viewthread_230/
Also there is a bunch of server side samples in the drop down menu forum (items data format is interchangeable):
http://www.softcomplex.com/forum/forumdisplay_29/


nashenvy - 12/4/2006 at 08:11 AM

hey i've done that there was mistake in driver


thanks a lot
:)


Softcomplex: http://www.softcomplex.com/
Back to forum: http://www.softcomplex.com/forum/