请教各位:
我可能说得比较唐僧一点:
我有一个jsp网页,分为左右两个Frame.
左边Fram是用javascript实现的一棵树。
这个树的内容是动态实现的,有很多级,来源于一个数组。
这个数组是用java实现的,具体是通过Jena组件读Ontology文件来实现的,估计要写几个嵌套的类。
这样,通过在树的文件tree.js中调用java类产生的数组来实现这个树的结构。
请问我何在tree.js中调用java类产生的数组?
希望大家指导我。
还有我能把这个放在struts架构中吗?
------解决方案--------------------
参看我下面的代码,不知道你是否会明白?
<script language= "JavaScript ">
var tree = new MzTreeView( "tree ");
tree.icons[ "property "] = "property.gif ";
tree.icons[ "css "] = "collection.gif ";
tree.icons[ "book "] = "book.gif ";
tree.iconsExpand[ "book "] = "bookopen.gif "; tree.setIconPath( "http://jsp/function/Icons/TreeView/ ");
<% Connection conn = null;
PreparedStatement pstmt=null;
ResultSet rs=null;
Class.forName( "oracle.jdbc.driver.OracleDriver ");
conn = DriverManager.getConnection( "jdbc:oracle:thin:@15.0.15:1521:dev ", "test ", "123456 ");
String sql = "Select chart_id,...... From table1 where empno=user_name order by chart_id ";
pstmt = (PreparedStatement) conn.prepareStatement(sql,ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_READ_ONLY);
rs = pstmt.executeQuery();
while(rs!=null && rs.next()){
%>
tree.nodes[ " <%=rs.getString( "parent_id ")%> _ <%=rs.getString( "chart_id ")%> "] = "text: <%=rs.getString( "name ")%> ;icon: <%=rs.getString( "icon ")%> ;url: <%=rs.getString( "url ")%> ;target: <%=rs.getString( "target ")%> ;method: <%=rs.getString( "method ")%> ;data:id= <%=rs.getString( "data ")%> ";
<% } %>
//tree.setURL( "Catalog.asp ");
//tree.setTarget( "MzMain ");
document.write(tree.toString());
</script>
------解决方案--------------------
去这里看看吧:
http://www.javadingle.com