com.gwtext.client.widgets.tree
Class TreeLoader

java.lang.Object
  extended by com.gwtext.client.core.JsObject
      extended by com.gwtext.client.widgets.tree.TreeLoader
Direct Known Subclasses:
XMLTreeLoader

public class TreeLoader
extends JsObject

A TreeLoader provides for lazy loading of an TreeNode's child nodes from a specified URL. The response must be a Json array definition who's elements are node definition objects. eg:

 

 [{ 'id': 1, 'text': 'A folder Node', 'leaf': false },
 { 'id': 2, 'text': 'A leaf Node', 'leaf': true }]

 
 
A server request is sent, and child nodes are loaded only when a node is expanded. The loading node's id is passed to the server under the parameter name "node" to enable the server to produce the correct child nodes.


Field Summary
protected  com.google.gwt.core.client.JavaScriptObject configJS
           
 
Fields inherited from class com.gwtext.client.core.JsObject
jsObj
 
Constructor Summary
TreeLoader()
          Create a new TreeLoader.
TreeLoader(com.google.gwt.core.client.JavaScriptObject jsObj)
           
 
Method Summary
 void addListener(TreeLoaderListener listener)
          Add a TreeLoader listener.
protected  com.google.gwt.core.client.JavaScriptObject create(com.google.gwt.core.client.JavaScriptObject config)
           
 com.google.gwt.core.client.JavaScriptObject getJsObj()
           
static TreeLoader instance(com.google.gwt.core.client.JavaScriptObject jsObj)
           
 void load()
          Load a TreeNode from the URL specified in the TreeLoader configuration.
 void load(Function callback)
          Load a TreeNode from the URL specified in the TreeLoader configuration.
 void setBaseAttrs(UrlParam[] params)
          The request parameters to be added to all nodes created by this loader.
 void setBaseParams(UrlParam[] params)
          Request properties which specify HTTP parameters to be passed to each request for child nodes.
 void setClearOnLoad(boolean clearOnLoad)
          Default to true.
 void setDataUrl(java.lang.String dataUrl)
          The URL from which to request a Json string which specifies an array of node definition object representing the child nodes to be loaded.
 void setMethod(Connection.Method method)
          The request method (GET OR POST).
 void setMethod(java.lang.String method)
          Deprecated. Use setMethod(com.gwtext.client.core.Connection.Method)
 void setPreloadChildren(boolean preloadChildren)
           
 
Methods inherited from class com.gwtext.client.core.JsObject
getProperties, isCreated, setJsObj
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

configJS

protected com.google.gwt.core.client.JavaScriptObject configJS
Constructor Detail

TreeLoader

public TreeLoader(com.google.gwt.core.client.JavaScriptObject jsObj)

TreeLoader

public TreeLoader()
Create a new TreeLoader.

Method Detail

getJsObj

public com.google.gwt.core.client.JavaScriptObject getJsObj()
Overrides:
getJsObj in class JsObject

create

protected com.google.gwt.core.client.JavaScriptObject create(com.google.gwt.core.client.JavaScriptObject config)

instance

public static TreeLoader instance(com.google.gwt.core.client.JavaScriptObject jsObj)

load

public void load()
Load a TreeNode from the URL specified in the TreeLoader configuration. This is called automatically when a node is expanded, but may be used to reload a node (or append new children if the clearOnLoad option is false.)


load

public void load(Function callback)
Load a TreeNode from the URL specified in the TreeLoader configuration. This is called automatically when a node is expanded, but may be used to reload a node (or append new children if the clearOnLoad option is false.)

Parameters:
callback - the callback to execute on load

addListener

public void addListener(TreeLoaderListener listener)
Add a TreeLoader listener.

Parameters:
listener - the listener

setBaseAttrs

public void setBaseAttrs(UrlParam[] params)
The request parameters to be added to all nodes created by this loader. If the attributes sent by the server have an attribute in this object, they take priority.

Parameters:
params - the url params

setDataUrl

public void setDataUrl(java.lang.String dataUrl)
The URL from which to request a Json string which specifies an array of node definition object representing the child nodes to be loaded.

Parameters:
dataUrl - the data URL

setPreloadChildren

public void setPreloadChildren(boolean preloadChildren)

setMethod

public void setMethod(Connection.Method method)
The request method (GET OR POST).

Parameters:
method - the request method
See Also:
Connection.GET, Connection.POST

setMethod

public void setMethod(java.lang.String method)
Deprecated. Use setMethod(com.gwtext.client.core.Connection.Method)

The request method (GET OR POST).

Parameters:
method - the request method

setBaseParams

public void setBaseParams(UrlParam[] params)
Request properties which specify HTTP parameters to be passed to each request for child nodes.

Parameters:
params - the request params

setClearOnLoad

public void setClearOnLoad(boolean clearOnLoad)
Default to true. Remove previously existing child nodes before loading.

Parameters:
clearOnLoad - true to clear on load