Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by H, Lee on Mar 13, 2009 01:53
open dhtmlx forum
Using JSp in DHTML xTree

Using JSp in DHTML xTree in Autoloading from JSON

I had test Autoloading from JSON by JSP.

i made jsp like below
node.jsp---------------------------------------------------------------------
<%@ page language ="java" contentType="text/xml" %>
<%@ page import="java.util.*" %>
<%
String nodeId = "";

if ( request.getParameter("id") == null || request.getParameter("id").equals("") ) {
    nodeId = "0";
}

String jasonData = "";

jasonData = jasonData + "{id:'" + nodeId + "', item:[\n";

for ( int inx = 0 ; inx < 5 ; inx++ ) {
    if ( inx != 0 ) {
        jasonData = jasonData + "," ;
    }
    jasonData = jasonData + "{id:'" + inx + "-"+ nodeId + "', text:'level 1-"
    + inx + "-" + nodeId + "', child:'1' }\n";
}

jasonData = jasonData + "]}\n";

%><%= jasonData %>
-------------------------------------------

and HTML code like this
test.html----------------------------------
.....................
            tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
            tree.setImagePath("./codebase/imgs/csh_bluebooks/");
            tree.setXMLAutoLoading("node.jsp");
            tree.setDataMode("json");
            tree.loadJSON("node.jsp?id=0");
.....................
---------------------------------------------

but error (xml reffers to not existing parent) occured.

as i know, DHTML was supported JSP.

and node.jsp result is same as json.php.

I don't know what i did wrong?;;;
Answer posted by Alex (support) on Mar 13, 2009 04:03

Probably, some important part is missed in your code. Please, try to add the highlighted line:

if ( request.getParameter("id") == null || request.getParameter("id").equals("") ) { 
  nodeId = "0"; 
}

else nodeId = request.getParameter("id");