|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.click.control.AbstractControl
net.sf.click.extras.tree.Tree
net.sf.click.extras.tree.CheckboxTree
public class CheckboxTree
Implementation of a tree control that provides checkboxes to enable selection of nodes. This implementation assumes the tree is wrapped inside a html form. Each time the form is submitted, all checkbox values are processed by this control.
Below is screenshot of how the tree will render in a browser.
|
public class PlainTreePage extends BorderPage { protected Submit okSubmit; protected Submit cancelSubmit; protected Form form; public PlainTreePage() { Tree tree = buildTree(); form = new Form("form"); form.add(tree); addControl(form); okSubmit = new Submit("okSubmit", "Select", this, "onSubmitClick"); cancelSubmit = new Submit("cancelSubmit", "Cancel", this, "onCancelClick"); form.add(okSubmit); form.add(cancelSubmit); } public Tree buildTree() { Tree tree = new CheckboxTree("tree"); // Build the tree model, by default the root node is not rendered. // This can be changed by calling setRootNodeDisplayed(true); TreeNode root = new TreeNode("c:"); TreeNode dev = new TreeNode("dev","1", root); new TreeNode("java.pdf", "2", dev); new TreeNode("ruby.pdf", "3", dev); TreeNode programFiles = new TreeNode("program files", "4", root); TreeNode adobe = new TreeNode("Adobe", "5", programFiles); // This node is a directory not a file, so setChildrenSupported to true. adobe.setChildrenSupported(true); TreeNode download = new TreeNode("downloads","6", root); TreeNode web = new TreeNode("web", "7", download); new TreeNode("html.pdf", "8", web); new TreeNode("css.html", "9", web); TreeNode databases = new TreeNode("databases", "10", download); new TreeNode("mysql.html","11",databases); new TreeNode("oracle.pdf","12",databases); new TreeNode("postgres","13",databases); tree.setRootNode(root); return tree; } }
Tree,
Serialized Form| Nested Class Summary | |
|---|---|
protected class |
CheckboxTree.BaseCheckboxJavascriptRenderer
Please note this class is only meant for developers of this control, not users. |
protected class |
CheckboxTree.CheckboxCookieHandler
Please note this class is only meant for developers of this control, not users. |
protected class |
CheckboxTree.CheckboxCookieJavascriptRenderer
Please note this class is only meant for developers of this control, not users. |
protected class |
CheckboxTree.CheckboxSessionHandler
Please note this class is only meant for developers of this control, not users. |
protected class |
CheckboxTree.CheckboxSessionJavascriptRenderer
Please note this class is only meant for developers of this control, not users. |
protected class |
CheckboxTree.DecoratorFactory
Demonstrates the usage of a decorator to provide custom tree node rendering. |
| Nested classes/interfaces inherited from class net.sf.click.extras.tree.Tree |
|---|
Tree.AbstractJavascriptRenderer, Tree.Callback, Tree.CookieHandler, Tree.CookieRenderer, Tree.JavascriptHandler, Tree.JavascriptRenderer, Tree.SessionHandler, Tree.SessionRenderer |
| Field Summary | |
|---|---|
static String |
HTML_IMPORTS
Client side javascript import. |
protected static String[] |
TREE_RESOURCES
The Tree resource file names. |
| Fields inherited from class net.sf.click.extras.tree.Tree |
|---|
COLLAPSE_ICON, EXPAND_ICON, EXPAND_TREE_NODE_PARAM, expandOrCollapseNodeIds, JAVASCRIPT_COOKIE_IMPORTS, JAVASCRIPT_COOKIE_POLICY, JAVASCRIPT_IMPORTS, JAVASCRIPT_SESSION_POLICY, javascriptHandler, LEAF_ICON, rootNode, SELECT_TREE_NODE_PARAM, selectOrDeselectNodeIds, TREE_IMAGES, TREE_IMPORTS |
| Fields inherited from class net.sf.click.control.AbstractControl |
|---|
actionListener, attributes, listener, listenerMethod, messages, name, parent, styles |
| Fields inherited from interface net.sf.click.Control |
|---|
CONTROL_MESSAGES |
| Constructor Summary | |
|---|---|
CheckboxTree()
Create a Tree with no name defined. |
|
CheckboxTree(String name)
Create an Tree control for the given name. |
|
| Method Summary | |
|---|---|
void |
bindRequestValue()
This method binds any expand/collapse changes from the request parameters. |
void |
bindSelectOrDeselectValues()
This method binds the users request of selected nodes to the tree's nodes. |
protected Tree.JavascriptHandler |
createJavascriptHandler(int javascriptPolicy)
Creates and return a new JavascriptHandler for the specified tree node. |
String |
getHtmlImports()
Return the HTML head import statements for the CSS stylesheet file: click/tree/checkbox-tree.js. |
boolean |
isSelectChildNodes()
Returns true if child nodes will also be selected/deselected. |
void |
onDeploy(ServletContext servletContext)
Deploy all files defined in the constant TREE_RESOURCES
to the click/tree web directory when the application is initialized. |
boolean |
postProcess()
Expand / collapse the tree nodes. |
void |
setSelectChildNodes(boolean selectChildNodes)
Sets whether child nodes will also be selected/deselected. |
| Methods inherited from class net.sf.click.control.AbstractControl |
|---|
addStyleClass, appendAttributes, getActionListener, getAttribute, getAttributes, getContext, getId, getMessage, getMessage, getMessage, getMessages, getName, getPage, getParent, getStyle, getStyles, getTag, hasAttribute, hasAttributes, hasStyles, onDestroy, onInit, onRender, registerActionEvent, removeStyleClass, renderTagBegin, renderTagEnd, setAttribute, setId, setName, setParent, setStyle |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String HTML_IMPORTS
Tree.
protected static final String[] TREE_RESOURCES
| Constructor Detail |
|---|
public CheckboxTree(String name)
name - the tree name
IllegalArgumentException - if the name is nullpublic CheckboxTree()
| Method Detail |
|---|
public boolean isSelectChildNodes()
public void setSelectChildNodes(boolean selectChildNodes)
JavaScript support is enabled.
selectChildNodes - determines if child nodes will be
selected/deselectedpublic String getHtmlImports()
getHtmlImports in interface ControlgetHtmlImports in class Treepublic void onDeploy(ServletContext servletContext)
TREE_RESOURCES
to the click/tree web directory when the application is initialized.
This method calls super.onDeploy() to copy any files defined in the
super class.
onDeploy in interface ControlonDeploy in class TreeservletContext - the servlet contextControl.onDeploy(ServletContext)public void bindSelectOrDeselectValues()
public void onInit() {
Tree tree = new Tree("tree");
Form form = new Form("form");
form.add(tree);
Submit submit = new Submit("submit");
form.add(submit);
submit.setActionListener(new ActionListener() {
public boolean onAction(Control source) {
tree.bindSelectOrDeselectValues();
return true;
}
});
addControl(form);
}
bindSelectOrDeselectValues in class Treepublic void bindRequestValue()
bindRequestValue in class TreeTree.bindExpandOrCollapseValues()public boolean postProcess()
protected Tree.JavascriptHandler createJavascriptHandler(int javascriptPolicy)
createJavascriptHandler in class TreejavascriptPolicy - the current javascript policy
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||