Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Monica on Aug 07, 2009 13:10
open dhtmlx forum
File Explorer in Java

Hi,

I am trying to use file explorer in my java struts app. I am using dynamic tree loading concept.

First of all my tree works in IE but not FF it says " XML or text declaration not start of entity" here is the jsp that I am calling

<%@ page import="com.beans.CreateFolderTree"%>
<%response.setContentType("text/xml");
out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
CreateFolderTree navFol = null;
navFol = new CreateFolderTree();
System.out.println("Inside JSP: ");
String strTree2 = navFol.getTree();
System.out.println("strTree2: "+strTree2);
out.println(strTree2);
%>

whats wrong in this?


2. In dynamic tree loading when u click on the node u need to send the ID of node in URL inorder to create XML for the node

how do I get the node ID to send it in the URL for serXMLAutoLoading

tree=myLayout.cells("a").attachTree("0");
        tree.setImagePath("dhtmlx/dhtmlxTree/codebase/imgs/");
        tree.loadXML("../test/test_tree.jsp");
        tree.setXMLAutoLoading("../test/test_tree.jsp?id=");
        var sID = tree.getSelectedItemId();
        alert("Selected Node: " + sID);
        alert("This node has children: "+tree.hasChildren(sID));

Thanks
I am new to this trying to redesign outr webpages with file explorer
Answer posted by Alex (support) on Aug 10, 2009 01:20

>> First of all my tree works in IE but not FF it says " XML or text declaration not start of entity" here is the jsp that I am calling

In case of FF the problem may occur because of any whitespace before <?xml declaraton (the declaration must be the first text in the output).

>> how do I get the node ID to send it in the URL for serXMLAutoLoading

You can use onXLE event:

tree.attachEvent("onXLE",function(tree,itemId){

...

})

Answer posted by Monica on Aug 10, 2009 07:31

I was able to fix the problem I had with FF.

But the second Issue regarding dynamic loading of tree menu how do I get the ID of the node that is clicked to send it in the URL used for tree.setXMLAutoLoading(url)

Ex: I have to call this URL in which I ahve to send the ID as query Parameter  "/web/XMLTree.do?ID="

 

 

Answer posted by Alex (support) on Aug 10, 2009 07:50

The id is sent automatically (the parameter name is id).

Please, read the article http://dhtmlx.com/docs/products/dhtmlxTree/doc/dyn_loading.html#dyntree

Answer posted on Aug 10, 2009 08:54

So Can I just do request.getParameter("id") in my server side program?

and set tree.setXMLAutoLoading("/web/XMLTree.do")

 

Answer posted by Alex (support) on Aug 10, 2009 09:30
Yes, you can.
Answer posted on Aug 10, 2009 11:49

I tried that. I am not getting ID in my server side program  :

ID from Tree: undefined

Here is what I has in my HTML

tree=myLayout.cells("a").attachTree("0");

tree.setImagePath("/dhtmlx/dhtmlxTree/codebase/imgs/");

tree.setXMLAutoLoading("/web/XMLTree.do");

tree.loadXML("/web/XMLTree.do?id=0");

tree.attachEvent("onSelect",showDirContent);

Here is what I had in my action class

 

public class XMLGrid extends Action {

public ActionForward execute(ActionMapping mapping, ActionForm form,

HttpServletRequest request, HttpServletResponse response)

throws Exception {

try{

System.out.println("ID from Tree: ");

String id = request.getParameter("id");

System.out.println("ID from Tree: "+ id);

PrintWriter out = response.getWriter();

response.setContentType("text/xml; charset=iso-8859-1");

response.setHeader("Cache-Control", "no-store, max-age=0, no-cache, must-revalidate");

response.addHeader("Cache-Control", "post-check=0, pre-check=0");

response.setHeader("Pragma", "no-cache");

out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");

CreateFolderTree navFol = null;

navFol = new CreateFolderTree("netlib", "dmadmin","180washington", "/" + "NSS");

System.out.println("Inside JSP: ");

String strTree2 = navFol.getTree();

System.out.println("strTree2: "+strTree2);

out.println(strTree2);

out.close();

return null;

} catch (Exception e){

return null;

}

}

}

Answer posted by Monica on Aug 10, 2009 12:54

This is my Intial XML

<?xml version=\"1.0\" encoding=\"UTF-8\"?>

<tree id="0">

<item text="DocResources" ID="/NSS/DocResources" im0="folderClosed.gif" child="1"/>

<item text="Exec" ID="/NSS/Exec" im0="folderClosed.gif" child="1"/>

<item text="_ApplicationsOps-Eng" ID="/NSS/_ApplicationsOps-Eng" im0="folderClosed.gif" child="1"/>

<item text="_ApplicationsRF-Perf" ID="/NSS/_ApplicationsRF-Perf" im0="folderClosed.gif" child="1"/>

</tree>

When I click on one of these Items I need the value spcified in the ID in the above XML in the server side program.

Answer posted by Monica on Aug 10, 2009 13:15
I got it in My XML I had id specified in uppercase ID="" thats y it didn't get the value.
Answer posted by Alex (support) on Aug 11, 2009 02:22

The correct root xml is:

<?xml version="1.0" encoding="UTF-8"?>
<tree id="0">
<item text="DocResources" id="/NSS/DocResources" im0="folderClosed.gif" child="1"/>

<item text="Exec" id="/NSS/Exec" im0="folderClosed.gif" child="1"/>

<item text="_ApplicationsOps-Eng" id="/NSS/_ApplicationsOps-Eng" im0="folderClosed.gif" child="1"/>

<item text="_ApplicationsRF-Perf" id="/NSS/_ApplicationsRF-Perf" im0="folderClosed.gif" child="1"/>

</tree>

Please, check case of teh id attribute

Answer posted on Aug 11, 2009 06:10
Thanks for ur help Alex