aspose file tools*
The moose likes Struts and the fly likes Need help understanding Dojo Struts2 ajax tree generation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Need help understanding Dojo Struts2 ajax tree generation" Watch "Need help understanding Dojo Struts2 ajax tree generation" New topic
Author

Need help understanding Dojo Struts2 ajax tree generation

Sheikh Alim
Greenhorn

Joined: Mar 22, 2010
Posts: 2
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.


[Thumbnail for example.JPG]

Sheikh Alim
Greenhorn

Joined: Mar 22, 2010
Posts: 2
Any hint ?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Need help understanding Dojo Struts2 ajax tree generation