visit count 3202455
RSS2.0
Artszen.org
+more Notice...
2010-01-15
JBoss User Group 오프라인 무료 교육
2009-05-26
소프트웨어진흥원 주관 POJO 기반의 OpenSource 웹 개발 프레임워크 실무 Workshop 과정 1차가 5월23일 시작되었습니다.
2009-05-13
세미나 개발 작업 진행
2009-05-13
컬럼 개발 작업 진행
2009-05-13
태그스토리 개발작업 진행
교육 안내
- 소프트웨어진흥원 2009년 맞춤형 S/W 인력양성 사업

Link Sites...
Apache Foundation
Struts
iBatis
Forrest
AppFuse
Prototype
Eclipse
TheServerSide
jBoss
jBoss jBPM
Artszen Software
인기 태그
스트럿츠2
struts2
servlet
서블릿
스트럿츠2 태그
struts2 tag
control tag
일반 태그
컨트롤 태그
generic tag
tag
FilterDispatcher
jsp
Action
struts2.0.9
액션
필터 디스패처
lifecycle
result
리절트
 
Struts2
<s:tree /> 태그를 이용하여 트리 컴포넌트를 사용하는 예제 hit 2131  

<s:tree /> 태그를 이용해서 트리를 구현하는 예제를 작성합니다.

결과는 다음과 같습니다.



[TreeNode.java: 모델 클래스]

package example.chapter6;

import java.util.ArrayList;
import java.util.List;

public class TreeNode {
    private String id;
    private String name;
    private List children = new ArrayList();
 
    public TreeNode() {}
 
    public TreeNode(String id, String name, TreeNode... children) {
        this.id = id;
        this.name = name;
        this.children = new ArrayList();
        for (TreeNode child : children) {
            this.children.add(child);
        }
    }

    public List getChildren() {return children;}
    public void setChildren(List children) {this.children = children;}
    public String getId() {return id;}
    public void setId(String id) {this.id = id;}
    public String getName() {return name;}
    public void setName(String name) {this.name = name;}
}


[TreeSampleAction.java : 액션 클래스]

package example.chapter6;

import com.opensymphony.xwork2.ActionSupport;

public class TreeSampleAction extends ActionSupport {
    private TreeNode nodeRoot;
 
    public String execute() throws Exception {

        nodeRoot = new TreeNode("00000", "00000",
                                      new TreeNode("10000", "10000",
                                                 new TreeNode("11000", "11000"), 
                                                 new TreeNode("12000", "12000")),
     
                                      new TreeNode("20000", "20000",
                                                 new TreeNode("21000", "21000"),
                                                 new TreeNode("22000", "22000"))
                            );
     
         return "success";
    }

    public TreeNode getNodeRoot() {return nodeRoot;}
    public void setNodeRoot(TreeNode nodeRoot) {this.nodeRoot = nodeRoot;}
}


[treeSample.jsp : JSP]

<%@ page contentType="text/html; charset=utf-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<html>
<head>
    <title>tree sample</title>
    <s:head theme="ajax" debug="true" />
</head>

<body>
    <s:tree
           theme="ajax"
           rootNode="%{nodeRoot}"
           childCollectionProperty="children"
           nodeIdProperty="id"
           nodeTitleProperty="name"
           templateCssPath="style/tree.css" toggle="fade"  />
</body>
</html>

[struts.xml : 설정파일]
...
  <action name="treeSample" class="example.chapter6.TreeSampleAction">
      <result>/chapter6/treeSample.jsp</result>
  </action>
...

2008-07-12 01:11:05   현철주  

  Tag
tree
<s:tree/>
이제호 2009-06-12 02:46:58
흠..트리에 아이템을 디비에서 불러와서 맵형태로 가공하려면 어떤 식으로 해야할까요? 아이디어가 쉽게 떠오르지 않네요- _-;;