Hello, someone with some example of how to use taglibrary s:tree of struts?

I'm having great difficulties, then the code below:

thanks for any help,


JSP:

<%@ taglib prefix="s" uri="/struts-tags" %>
s
<!--
  - @attrib rootNode
  -             OGNL value holding top-level tree node.
  - @attrib childCollectionProperty
  -             Property of rootNode containing child nodes.
  - @attrib nodeIdProperty
  -             Property of each node containing "value" of node, like an
ID.
  - @attrib nodeTitleProperty
  -             Property of each node containing tree label text.
  -->
<s:tree theme="ajax"
        rootNode="%{rootNode}"
        childCollectionProperty="children"
        nodeIdProperty="id"
        nodeTitleProperty="name">
</s:tree>

ACTION:
package action;

import bean.TreeModel;

import com.opensymphony.xwork2.ActionSupport;

/**
 * Fragment of Action class showing the minimum necessary to support the
 * following JSP code. Getters, setters, functionality not shown.
 */
public class ShowTreeAction extends ActionSupport{
    private TreeModel _rootNode;      // Top-level tree node.

    public String show(){

        TreeModel tm = new TreeModel();

        tm.set_id(new Long(56));
        tm.set_name("aaaaa");

        set_rootNode(tm);

        return SUCCESS;
    }

    public TreeModel get_rootNode() {
        return _rootNode;
    }

    public void set_rootNode(TreeModel node) {
        _rootNode = node;
    }
}


TreeModel

package bean;

import java.util.Set;

public class TreeModel {
    private Long _id;                 // Node's ID.
    private String _name;             // Node's name property.
    private Set<TreeModel> _children; // Node's children.


    public Long get_id() {
        return _id;
    }
    public void set_id(Long _id) {
        this._id = _id;
    }
    public String get_name() {
        return _name;
    }
    public void set_name(String _name) {
        this._name = _name;
    }
    public Set<TreeModel> get_children() {
        return _children;
    }
    public void set_children(Set<TreeModel> _children) {
        this._children = _children;
    }


}

Reply via email to