Hi,
I am trying to generate a tree using dojo. The version of
struts i am using is 2.1.8.
The issue I'm facing is understanding how the child collection property works with dojo tree.
Below is my code for tree generation:
<sx:tree id="tree" childCollectionProperty="children" href="/orgchart/action/default" />
I'm using a
jsp to build the supporting JSON
string:
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<c:set var="counter" value="0"></c:set>
[
<s:iterator value="employeeList" var="item">
{
label: "<s:property value='%{#item.empName}' />",
hasChildren:<s:if test='%{#item.isManager == "YES"}'>true,</s:if><s:else>false,</s:else>
id: "<s:property value='%{#item.employeeID}' />"
}
<c:set var="counter" value="${counter + 1 }"></c:set>
<c:if test="${counter < lenght }">,</c:if>
</s:iterator>
]
Now this is rendering the tree as shown in the attached image.
What i fail to understand is how to show one json item as a child of another!
A look at the attached image will reveal that Level -2 should be the root, level -1 its child and accordingly.
But this (as explained in struts2 api) way of building the json does not explain the child collection.
Any help would be greatly appreciated. This is becoming a major roadblock for me.