Dhtmlx Tree Struts2 Sample

Dear All,

Can you please provide one dhtmlxtree and struts2 example.Instead of Tree following xml rendering on my jsp page.Can u suggest me where i need to amend my code.I have display this tree on my layout cell.

 <?xml version="1.0" encoding="UTF-8" ?> 
- <tree id="0">
- <item text="Physics" id="work console" im0="folderClosed.gif" im1="folderOpen.gif" im2="folderClosed.gif">
  <item text="Chemistry" id="working" im0="book_titel.gif" im1="fbook.gif" im2="book_titel.gif" /> 
  <item text="Maths" id="working" im0="book_titel.gif" im1="fbook.gif" im2="book_titel.gif" /> 
  </item>
  </tree>

javascript code

<script type="text/javascript">	
var dhxLayout = new dhtmlXLayoutObject(document.body, "4E", skin);

	dhxLayout.cells("c").attachURL("loadBookLib.do");



dhxLayout.cells("a").attachObject("formTree");
dhxLayout.cells("b").attachObject("TreeDiv");	
//dhxLayout.cells("d").attachObject("ftrLayt");	



dhxLayout.cells("a").hideHeader();
dhxLayout.cells("b").hideHeader();
dhxLayout.cells("c").hideHeader();
//dhxLayout.cells("d").hideHeader();



dhxLayout.cells("a").setHeight(68);
dhxLayout.cells("b").setHeight(9);
dhxLayout.cells("c").setHeight(500);
//dhxLayout.cells("d").setHeight(10);


dhxLayout.cells("a").fixSize(true, true); 
dhxLayout.cells("b").fixSize(true, true);
dhxLayout.cells("c").fixSize(true, true);
//dhxLayout.cells("d").fixSize(true, true);


var arr=[];

arr["a"] = dhxLayout.cells("a").getHeight(); 
arr["b"] = dhxLayout.cells("b").getHeight();
arr["c"] = dhxLayout.cells("c").getHeight();
//arr["d"] = dhxLayout.cells("d").getHeight();


dhxLayout.attachEvent("onExpand",function(id){
    for(var a in arr){
        this.cells(a).setHeight(arr[a]);
    }
    return true;
})

var menu = new dhtmlXTreeObject("menuObj","100%","100%",0);
menu.setImagePath("resource/imgs/csh_dhx_skyblue/");
menu.enableCheckBoxes(0);
menu.enableDragAndDrop(0);
menu.loadXML("bookMenuLib");


</script>

</body>
</html>

Hi,
unfortunately we don’t have a demo for dhtmlxTree + Struts 2, but actually it’s not so hard to implement.
You may create view which just outputs tree data:

<%@ taglib prefix="s" uri="/struts-tags" %>
<s:property escape="false" value="messageStore.data" />

Also you should configure routing in struts.xml:

<action name="treedata" class="org.apache.struts.demoapp_struts.action.LoadingAction" method="treedata">
	<result name="success">/data.jsp</result>
</action>

And finally you should add related method in action class:

public String treedata() throws Exception {
	messageStore.setData(data_in_json_as_string);
	return SUCCESS;
	}