Struts -jQuery树的递归问题

时间:2013-12-11 12:50:28

标签: jquery jsp jquery-plugins struts2

我正在使用struts jQuery树标签我能够生成动态树示例。这里的问题是树正在生成递归

JSP

 <!DOCTYPE html> 
 <%@ taglib prefix="s" uri="/struts-tags"%>
 <%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
 <%@ taglib prefix="sjt" uri="/struts-jquery-tree-tags"%>
  <html >

<head>
<sj:head jqueryui="true" jquerytheme="redmond"/>
 </head>



    <s:url var="echo" action="echo"/>
    <sjt:tree  
            id="treeDynamicAjax" 
            href="%{echo}"
            jstreetheme = "default"
            onClickTopics="treeClicked"


              />

  </html>

动作类

    import java.util.LinkedList;

    import com.jgeppert.struts2.jquery.tree.result.TreeNode;
    import com.opensymphony.xwork2.ActionSupport;

     public class TreeDynamicAction extends ActionSupport {

 /**
 * 
 */
private static final long serialVersionUID = 1L;
private TreeNode nodes;

public TreeDynamicAction() {
    this.nodes = new TreeNode(); 
}

  public String execute() {
      TreeNode nodeA = new TreeNode();
      nodeA.setId("A");
      nodeA.setTitle("Node A");
      nodeA.setState("open");

      TreeNode nodeAA = new TreeNode();
      nodeAA.setId("AA");
      nodeAA.setTitle("Node AA");


      TreeNode nodeAB = new TreeNode();
      nodeAB.setId("AB");
      nodeAB.setTitle("Node AB");

      nodeA.setChildren(new LinkedList<TreeNode>());
      nodeA.getChildren().add(nodeAA);
      nodeA.getChildren().add(nodeAB);

      TreeNode nodeB = new TreeNode();
      nodeB.setId("B");
      nodeB.setTitle("Node B");

      TreeNode nodeC = new TreeNode();
      nodeC.setId("C");
      nodeC.setTitle("Node C");

      this.nodes.setId("rootNode");
      this.nodes.setTitle("Root Node");
      this.nodes.setState("open");

      this.nodes.setChildren(new LinkedList<TreeNode>());
      this.nodes.getChildren().add(nodeA);
      this.nodes.getChildren().add(nodeB);
      this.nodes.getChildren().add(nodeC);

     return "success";
 }


 public TreeNode getNodes() {
    return nodes;
}

public void setNodes(TreeNode nodes) {
    this.nodes = nodes;
}

 public String getJSON() {
     return execute();
    }
    }

struts.xml中

 <package name="testWeb" extends="struts-default,json-default">
    <result-types>
        <result-type name="json" class="org.apache.struts2.json.JSONResult" />
    </result-types>

   <action name="echo" class="com.web.action.TreeDynamicAction">
        <result name="success" type="json" >
            <param name="root">nodes</param>
         </result>  
    </action>


</package>

我很确定我使用的标签不正确,但我找不到任何有用的新手应用文档。 提前谢谢

0 个答案:

没有答案