You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 10 Next »

Description

Error formatting macro: snippet: java.lang.NullPointerException

Quick Example

This example describes basic usage of the <s:tree.../> tag showing both the model behind the tree and the JSP fragment that uses it. This section of the documentation is a work-in-progress; more to follow.

Backing Model
/**
 * In this example it is assumed that the backing POJO is a tree-like structure
 * consisting of same-type elements, roughly like the following, with getters
 * and setters not shown for clarity.
 *
 * This could be, say, a Hibernate/etc. POJO stored in a database and loaded lazily, etc.
 *
 * TODO Determine allowable collection types; I know for a fact Set works.
 */
public class TreeModel {
    private Long _id;                 // Node's ID.
    private String _name;             // Node's name property.
    private Set<TreeModel> _children; // Node's children.
}
Action
/**
 * Fragment of Action class showing the minimum necessary to support the
 * following JSP code. Getters, setters, functionality not shown.
 */
public class ShowTreeAction {
    private TreeModel _rootNode;      // Top-level tree node.
}
JSP
<!-- 
  - @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>

Parameters

Error formatting macro: snippet: java.lang.NullPointerException

Examples

Error formatting macro: snippet: java.lang.NullPointerException
  • No labels