JTree Samples

Here samples of usage of the JTree applet are listed...

Simple tree:

Tree with checkboxes:

Dynamic loading - ASP code sample: zip (14 kB)

<%
parentID=Request("id")

dbDir = Server.MapPath("data.mdb")
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open "DBQ="& dbDir &";Driver={Microsoft Access Driver (*.mdb)};FIL=MS Access;"
Set rs = Conn.Execute("select * from child where parentid=" & parentID)
do while not rs.EoF
	id=rs("childid")
	name = rs("name")
	response.write """" & name & """,""" & id & """,""1,'" & id & "'"",0"
	response.write vbCrLf
	rs.movenext
loop
rs.close
%>

Dynamic loading - JSP code sample: zip (14 kB)

<%
String parentID = request.getParameter("id");

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:jtree");
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("select * from child where parentid=" + parentID);

while (rs.next())
{
	String id=rs.getString("childid");
	String name = rs.getString("name");
	out.println("\"" + name + "\",\"" + id + "\",\"1,'" + id + "'\",0");
}

rs.close();
st.close();
conn.close();
%>

Questions or comments? Write us, you are always welcome.
Check our other products.