org.zkoss.zul
Class Tree

java.lang.Object
  extended by org.zkoss.zk.ui.AbstractComponent
      extended by org.zkoss.zk.ui.HtmlBasedComponent
          extended by org.zkoss.zul.impl.XulElement
              extended by org.zkoss.zul.Tree
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, HtmlBasedComponent, Component, Scope, ComponentCtrl, Tree, Paginated, XulElement

public class Tree
extends XulElement
implements Paginated, Tree

A container which can be used to hold a tabular or hierarchical set of rows of elements.

Event:

  1. org.zkoss.zk.ui.event.SelectEvent is sent when user changes the selection.

Default getZclass(): z-tree, and an other option is z-dottree. (since 3.5.0)

Author:
tomyeh
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.zkoss.zk.ui.HtmlBasedComponent
HtmlBasedComponent.ExtraCtrl
 
Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent
AbstractComponent.Children
 
Field Summary
 
Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent
_height, _left, _top, _width, _zclass
 
Fields inherited from class org.zkoss.zk.ui.AbstractComponent
_visible
 
Fields inherited from interface org.zkoss.zk.ui.Component
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE
 
Fields inherited from interface org.zkoss.zk.ui.sys.ComponentCtrl
CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE
 
Constructor Summary
Tree()
           
 
Method Summary
 void addItemToSelection(Treeitem item)
          Selects the given item, without deselecting any other items that are already selected..
 void addItemToSelectionApi(Treeitem itemApi)
          Selects the given item, without deselecting any other items that are already selected..
 void beforeChildAdded(Component newChild, Component refChild)
          Default: does nothing.
 void clear()
          Clears all child tree items (Treeitem.
 void clearSelection()
          Clears the selection.
 java.lang.Object clone()
          Clones the component.
 int getActivePage()
          Returns the active page (starting from 0).
protected  java.lang.Object getAssociatedNode(Treeitem ti, Tree t)
          Return a node which is an associated Treeitem ti in a Tree tree
protected  Component getChildByNode(java.lang.Object node)
          Return the Tree or Treeitem component by a given associated node in model.
 java.util.Collection getHeads()
          Returns a collection of heads, including getTreecols() and auxiliary heads (Auxhead) (never null).
 java.lang.String getInnerWidth()
          Returns the inner width of this component.
 int getItemCount()
          Returns the number of child Treeitem.
 java.util.Collection getItems()
          Returns a readonly list of all descending Treeitem (children's children and so on).
 TreeModel getModel()
          Returns the list model associated with this tree, or null if this tree is not associated with any tree data model.
 java.lang.String getName()
          Returns the name of this component.
 int getPageCount()
          Returns the number of pages.
 int getPageSize()
          Returns the page size, aka., the number items per page.
 Paginal getPaginal()
          Returns the paging controller, or null if not available.
 Paging getPagingChild()
          Returns the child paging controller that is created automatically, or null if mold is not "paging", or the controller is specified externally by setPaginal(org.zkoss.zul.ext.Paginal).
 Paging getPagingChildApi()
          Returns the child paging controller that is created automatically, or null if mold is not "paging", or the controller is specified externally by setPaginal(org.zkoss.zul.ext.Paginal).
 java.lang.String getPagingPosition()
          Returns how to position the paging of tree at the client screen.
 int getRows()
          Returns the rows.
 int getSelectedCount()
          Returns the number of items being selected.
 Treeitem getSelectedItem()
          Returns the selected item.
 Treeitem getSelectedItemApi()
          Returns the selected item.
 java.util.Set getSelectedItems()
          Returns all selected items.
 java.lang.String getSeltype()
          Returns the seltype.
 Treechildren getTreechildren()
          Returns the treechildren that this tree owns (might null).
 Treechildren getTreechildrenApi()
          Returns the treechildren that this tree owns (might null).
 Treecols getTreecols()
          Returns the treecols that this tree owns (might null).
 Treecols getTreecolsApi()
          Returns the treecols that this tree owns (might null).
 Treefoot getTreefoot()
          Returns the treefoot that this tree owns (might null).
 Treefoot getTreefootApi()
          Returns the treefoot that this tree owns (might null).
 TreeitemRenderer getTreeitemRenderer()
          Returns the renderer to render each item, or null if the default renderer is used.
 java.lang.String getZclass()
          Returns the ZK Cascading Style class(es) for this component.
 boolean insertBefore(Component newChild, Component refChild)
          Inserts a child before the reference child.
 boolean isCheckmark()
          Returns whether the check mark shall be displayed in front of each item.
 boolean isFixedLayout()
          Deprecated. since 5.0.0, use !isSizedByContent() instead
 boolean isMultiple()
          Returns whether multiple selections are allowed.
 boolean isSizedByContent()
          Returns whether sizing tree grid column width by its content.
 boolean isVflex()
          Returns whether to grow and shrink vertical to fit their given space, so called vertial flexibility.
 void onChildAdded(Component child)
          Default: does nothing.
 void onChildRemoved(Component child)
          Default: does nothing.
protected  void redrawChildren(java.io.Writer out)
          Redraws childrens (and then recursively descandants).
 void removeItemFromSelection(Treeitem item)
          Deselects the given item without deselecting other items.
 void removeItemFromSelectionApi(Treeitem itemApi)
          Deselects the given item without deselecting other items.
 void renderItem(Treeitem item)
          Renders the specified Treeitem, if not loaded yet, with getTreeitemRenderer().
 void renderItem(Treeitem item, java.lang.Object node)
          Renders the specified Treeitem, if not loaded yet, with getTreeitemRenderer().
 void renderItemApi(Treeitem itemApi)
          Renders the specified Treeitem, if not loaded yet, with getTreeitemRenderer().
 void renderItemApi(Treeitem itemApi, java.lang.Object node)
          Renders the specified Treeitem, if not loaded yet, with getTreeitemRenderer().
 Treeitem renderItemByPath(int[] path)
          Load treeitems through path path
Note: By using this method, all treeitems in path will be rendered and opened (Treeitem.setOpen(boolean)).
 Treeitem renderItemByPathApi(int[] path)
          Load treeitems through path path
Note: By using this method, all treeitems in path will be rendered and opened (Treeitem.setOpen(boolean)).
 void renderItems(java.util.Set items)
          Renders the specified Treeitem if not loaded yet, with getTreeitemRenderer().
protected  void renderProperties(ContentRenderer renderer)
          Renders the content of this component, excluding the enclosing tags and children.
 void selectAll()
          Selects all items.
 void selectItem(Treeitem item)
          Deselects all of the currently selected items and selects the given item.
 void selectItemApi(Treeitem itemApi)
          Deselects all of the currently selected items and selects the given item.
 void service(AuRequest request, boolean everError)
          Processes an AU request.
 void setActivePage(int pg)
          Sets the active page (starting from 0).
 void setActivePage(Treeitem item)
          Sets the active page in which the specified item is.
 void setActivePageApi(Treeitem itemApi)
          Sets the active page in which the specified item is.
 void setCheckmark(boolean checkmark)
          Sets whether the check mark shall be displayed in front of each item.
 void setFixedLayout(boolean fixedLayout)
          Deprecated. since 5.0.0, use setSizedByContent(boolean)(!fixedLayout) instead
 void setInnerWidth(java.lang.String innerWidth)
          Sets the inner width of this component.
 void setModel(TreeModel model)
          Sets the tree model associated with this tree.
 void setMold(java.lang.String mold)
          Sets the mold to render this component.
 void setMultiple(boolean multiple)
          Sets whether multiple selections are allowed.
 void setName(java.lang.String name)
          Sets the name of this component.
 void setPageSize(int pgsz)
          Sets the page size, aka., the number items per page.
 void setPaginal(Paginal pgi)
          Specifies the paging controller.
 void setPagingPosition(java.lang.String pagingPosition)
          Sets how to position the paging of tree at the client screen.
 void setRows(int rows)
          Sets the rows.
 void setSelectedItem(Treeitem item)
          Deselects all of the currently selected items and selects the given item.
 void setSelectedItemApi(Treeitem itemApi)
          Deselects all of the currently selected items and selects the given item.
 void setSeltype(java.lang.String seltype)
          Sets the seltype.
 void setSizedByContent(boolean byContent)
          Sets whether sizing tree grid column width by its content.
 void setTreeitemRenderer(TreeitemRenderer renderer)
          Sets the renderer which is used to render each item if getModel() is not null.
 void setVflex(boolean vflex)
          Sets whether to grow and shrink vertical to fit their given space, so called vertial flexibility.
protected  void smartUpdate(java.lang.String attr, java.lang.Object value)
          Smart-updates a property of the peer widget associated with the component, running at the client, with the specified value.
 void toggleItemSelection(Treeitem item)
          If the specified item is selected, it is deselected.
 void toggleItemSelectionApi(Treeitem itemApi)
          If the specified item is selected, it is deselected.
 
Methods inherited from class org.zkoss.zul.impl.XulElement
getAction, getContext, getCtrlKeys, getPopup, getTooltip, setAction, setContext, setContext, setCtrlKeys, setPopup, setPopup, setTooltip, setTooltip
 
Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
focus, getDraggable, getDroppable, getHeight, getHflex, getLeft, getSclass, getStyle, getTooltiptext, getTop, getVflex, getWidth, getZindex, getZIndex, newExtraCtrl, setClass, setDraggable, setDroppable, setFocus, setHeight, setHflex, setLeft, setSclass, setStyle, setTooltiptext, setTop, setVflex, setWidth, setZclass, setZindex, setZIndex
 
Methods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addAnnotation, addClientEvent, addEventHandler, addEventListener, addForward, addForward, addForward, addForward, addMoved, addScopeListener, addSharedAnnotationMap, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildRemoved, beforeParentChanged, containsVariable, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableClientUpdate, equals, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getChildren, getClientEvents, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getExtraCtrl, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getId, getLastChild, getListenerIterator, getMold, getNamespace, getNextSibling, getPage, getParent, getPreviousSibling, getRoot, getSpaceOwner, getUuid, getVariable, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasFellow, hasFellow, invalidate, isChildable, isInvalidated, isListenerAvailable, isVisible, newChildren, onPageAttached, onPageDetached, onWrongValue, redraw, removeAttribute, removeAttribute, removeAttribute, removeChild, removeEventListener, removeForward, removeForward, removeScopeListener, render, render, render, response, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setAttribute, setAuService, setDefinition, setDefinition, setId, setPage, setPageBefore, setParent, setVariable, setVisible, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, unsetVariable, updateByClient, willPassivate, willPassivate, willSerialize, willSerialize
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.zkoss.zul.impl.api.XulElement
getAction, getContext, getCtrlKeys, getPopup, getTooltip, setAction, setContext, setContext, setCtrlKeys, setPopup, setPopup, setTooltip, setTooltip
 
Methods inherited from interface org.zkoss.zk.ui.api.HtmlBasedComponent
focus, getHeight, getLeft, getSclass, getStyle, getTooltiptext, getTop, getWidth, getZindex, getZIndex, setDraggable, setDroppable, setFocus, setHeight, setLeft, setSclass, setStyle, setTooltiptext, setTop, setWidth, setZclass, setZindex, setZIndex
 
Methods inherited from interface org.zkoss.zk.ui.Component
addEventListener, addForward, addForward, addForward, addForward, appendChild, applyProperties, containsVariable, detach, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getChildren, getDefinition, getDesktop, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getId, getLastChild, getListenerIterator, getMold, getNamespace, getNextSibling, getPage, getParent, getPreviousSibling, getRoot, getSpaceOwner, getUuid, getVariable, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttributeOrFellow, hasFellow, hasFellow, invalidate, isInvalidated, isListenerAvailable, isVisible, removeAttribute, removeAttribute, removeChild, removeEventListener, removeForward, removeForward, setAttribute, setAttribute, setAuService, setId, setPage, setPageBefore, setParent, setVariable, setVisible, setWidgetListener, setWidgetOverride, unsetVariable
 
Methods inherited from interface org.zkoss.zk.ui.ext.Scope
addScopeListener, getAttribute, hasAttribute, removeAttribute, removeScopeListener, setAttribute
 

Constructor Detail

Tree

public Tree()
Method Detail

setMold

public void setMold(java.lang.String mold)
Description copied from interface: Component
Sets the mold to render this component.

Specified by:
setMold in interface Component
Overrides:
setMold in class AbstractComponent
Parameters:
mold - the mold. If null or empty, "default" is assumed.
See Also:
ComponentDefinition

setPagingPosition

public void setPagingPosition(java.lang.String pagingPosition)
Sets how to position the paging of tree at the client screen. It is meaningless if the mold is not in "paging".

Specified by:
setPagingPosition in interface Tree
Parameters:
pagingPosition - how to position. It can only be "bottom" (the default), or "top", or "both".
Since:
3.0.7

getPagingPosition

public java.lang.String getPagingPosition()
Returns how to position the paging of tree at the client screen. It is meaningless if the mold is not in "paging".

Specified by:
getPagingPosition in interface Paginated
Since:
3.0.7

getPaginal

public Paginal getPaginal()
Returns the paging controller, or null if not available. Note: the paging controller is used only if AbstractComponent.getMold() is "paging".

If mold is "paging", this method never returns null, because a child paging controller is created automcatically (if not specified by developers with setPaginal(org.zkoss.zul.ext.Paginal)).

If a paging controller is specified (either by setPaginal(org.zkoss.zul.ext.Paginal), or by setMold(java.lang.String) with "paging"), the tree will rely on the paging controller to handle long-content instead of scrolling.

Specified by:
getPaginal in interface Tree
Since:
3.0.7

setPaginal

public void setPaginal(Paginal pgi)
Description copied from interface: Tree
Specifies the paging controller. Note: the paging controller is used only if Component.getMold() is "paging".

It is OK, though without any effect, to specify a paging controller even if mold is not "paging".

Specified by:
setPaginal in interface Tree
Parameters:
pgi - the paging controller. If null and Component.getMold() is "paging", a paging controller is created automatically as a child component (see Tree.getPagingChildApi() ).

getPagingChild

public Paging getPagingChild()
Returns the child paging controller that is created automatically, or null if mold is not "paging", or the controller is specified externally by setPaginal(org.zkoss.zul.ext.Paginal).

Since:
3.0.7

getPagingChildApi

public Paging getPagingChildApi()
Returns the child paging controller that is created automatically, or null if mold is not "paging", or the controller is specified externally by setPaginal(org.zkoss.zul.ext.Paginal).

Specified by:
getPagingChildApi in interface Tree
Since:
3.5.2

getPageSize

public int getPageSize()
Returns the page size, aka., the number items per page.

Specified by:
getPageSize in interface Tree
Throws:
java.lang.IllegalStateException - if getPaginal() returns null, i.e., mold is not "paging" and no external controller is specified.
Since:
2.4.1

setPageSize

public void setPageSize(int pgsz)
                 throws WrongValueException
Sets the page size, aka., the number items per page.

Note: mold is not "paging" and no external controller is specified.

Specified by:
setPageSize in interface Tree
Throws:
WrongValueException
Since:
2.4.1

getPageCount

public int getPageCount()
Returns the number of pages. Note: there is at least one page even no item at all.

Specified by:
getPageCount in interface Tree
Since:
3.0.7

getActivePage

public int getActivePage()
Returns the active page (starting from 0).

Specified by:
getActivePage in interface Tree
Since:
3.0.7

setActivePage

public void setActivePage(int pg)
                   throws WrongValueException
Sets the active page (starting from 0).

Specified by:
setActivePage in interface Tree
Throws:
WrongValueException
Since:
3.0.7

setFixedLayout

public void setFixedLayout(boolean fixedLayout)
Deprecated. since 5.0.0, use setSizedByContent(boolean)(!fixedLayout) instead

Description copied from interface: Tree
Sets the outline of grid whether is fixed layout. If true, the outline of grid will be depended on browser. It means, we don't calculate the width of each cell. Otherwise, the outline will count on the content of body. In other words, the outline of grid is like ZK 2.4.1 version that the header's width is only for reference.

You can also specify the "fixed-layout" attribute of component in lang-addon.xml directly, it's a top priority.

Specified by:
setFixedLayout in interface Tree
Parameters:
fixedLayout - true to outline this grid by browser

isFixedLayout

public boolean isFixedLayout()
Deprecated. since 5.0.0, use !isSizedByContent() instead

Description copied from interface: Tree
Returns the outline of grid whether is fixed layout.

Default: false.

Note: if the "fixed-layout" attribute of component is specified, it's prior to the original value.

Specified by:
isFixedLayout in interface Tree

setSizedByContent

public void setSizedByContent(boolean byContent)
Sets whether sizing tree grid column width by its content. Default is false, i.e. the outline of grid is dependent on browser. It means, we don't calculate the width of each cell. if set to true, the outline will count on the content of body. In other words, the outline of grid will be like ZK version 2.4.1 that the header's width is only for reference.

You can also specify the "sized-by-content" attribute of component in lang-addon.xml directly, it will then take higher priority.

Specified by:
setSizedByContent in interface Tree
Parameters:
byContent -
Since:
5.0.0

isSizedByContent

public boolean isSizedByContent()
Returns whether sizing tree grid column width by its content. Default is false.

Note: if the "sized-by-content" attribute of component is specified, it's prior to the original value.

Specified by:
isSizedByContent in interface Tree
Since:
5.0.0
See Also:
setSizedByContent(boolean)

getTreecols

public Treecols getTreecols()
Returns the treecols that this tree owns (might null).


getTreecolsApi

public Treecols getTreecolsApi()
Returns the treecols that this tree owns (might null).

Specified by:
getTreecolsApi in interface Tree
Since:
3.5.2

getTreefoot

public Treefoot getTreefoot()
Returns the treefoot that this tree owns (might null).


getTreefootApi

public Treefoot getTreefootApi()
Returns the treefoot that this tree owns (might null).

Specified by:
getTreefootApi in interface Tree
Since:
3.5.2

getTreechildren

public Treechildren getTreechildren()
Returns the treechildren that this tree owns (might null).


getTreechildrenApi

public Treechildren getTreechildrenApi()
Returns the treechildren that this tree owns (might null).

Specified by:
getTreechildrenApi in interface Tree
Since:
3.5.2

getHeads

public java.util.Collection getHeads()
Returns a collection of heads, including getTreecols() and auxiliary heads (Auxhead) (never null).

Specified by:
getHeads in interface Tree
Since:
3.0.0

getRows

public int getRows()
Returns the rows. Zero means no limitation.

Default: 0.

Specified by:
getRows in interface Tree

setRows

public void setRows(int rows)
             throws WrongValueException
Sets the rows.

Note: if both HtmlBasedComponent.setHeight(java.lang.String) is specified with non-empty, setRows(int) is ignored

Specified by:
setRows in interface Tree
Throws:
WrongValueException

getName

public java.lang.String getName()
Returns the name of this component.

Default: null.

The name is used only to work with "legacy" Web application that handles user's request by servlets. It works only with HTTP/HTML-based browsers. It doesn't work with other kind of clients.

Don't use this method if your application is purely based on ZK's event-driven model.

Specified by:
getName in interface Tree

setName

public void setName(java.lang.String name)
Sets the name of this component.

The name is used only to work with "legacy" Web application that handles user's request by servlets. It works only with HTTP/HTML-based browsers. It doesn't work with other kind of clients.

Don't use this method if your application is purely based on ZK's event-driven model.

Specified by:
setName in interface Tree
Parameters:
name - the name of this component.

isCheckmark

public boolean isCheckmark()
Returns whether the check mark shall be displayed in front of each item.

Default: false.


setCheckmark

public void setCheckmark(boolean checkmark)
Sets whether the check mark shall be displayed in front of each item.

The check mark is a checkbox if isMultiple() returns true. It is a radio button if isMultiple() returns false.

Specified by:
setCheckmark in interface Tree

isVflex

public boolean isVflex()
Returns whether to grow and shrink vertical to fit their given space, so called vertial flexibility.

Note: this attribute is ignored if setRows(int) is specified

Default: false.


setVflex

public void setVflex(boolean vflex)
Sets whether to grow and shrink vertical to fit their given space, so called vertial flexibility.

Note: this attribute is ignored if setRows(int) is specified

Specified by:
setVflex in interface Tree

setInnerWidth

public void setInnerWidth(java.lang.String innerWidth)
Sets the inner width of this component. The inner width is the width of the inner table. By default, it is 100%. That is, it is the same as the width of this component. However, it is changed when the user is sizing the column's width.

Application developers rarely call this method, unless they want to preserve the widths of sizable columns changed by the user. To preserve the widths, the developer have to store the widths of all columns and the inner width (getInnerWidth()), and then restore them when re-creating this component.

Specified by:
setInnerWidth in interface Tree
Parameters:
innerWidth - the inner width. If null, "100%" is assumed.
Since:
3.0.0

getInnerWidth

public java.lang.String getInnerWidth()
Returns the inner width of this component. The inner width is the width of the inner table.

Default: "100%"

Specified by:
getInnerWidth in interface Tree
Since:
3.0.0
See Also:
setInnerWidth(java.lang.String)

getSeltype

public java.lang.String getSeltype()
Returns the seltype.

Default: "single".

Specified by:
getSeltype in interface Tree

setSeltype

public void setSeltype(java.lang.String seltype)
                throws WrongValueException
Sets the seltype. Currently, only "single" is supported.

Specified by:
setSeltype in interface Tree
Throws:
WrongValueException

isMultiple

public boolean isMultiple()
Returns whether multiple selections are allowed.

Default: false.

Specified by:
isMultiple in interface Tree

setMultiple

public void setMultiple(boolean multiple)
Sets whether multiple selections are allowed.

Specified by:
setMultiple in interface Tree

setActivePage

public void setActivePage(Treeitem item)
Sets the active page in which the specified item is. The active page will become the page that contains the specified item.

Parameters:
item - the item to show. If the item is null, invisible, or doesn't belong to the same tree, nothing happens.
Since:
3.0.4

setActivePageApi

public void setActivePageApi(Treeitem itemApi)
Sets the active page in which the specified item is. The active page will become the page that contains the specified item.

Specified by:
setActivePageApi in interface Tree
Parameters:
itemApi - assume as a Treeitem
Since:
3.5.2

getItems

public java.util.Collection getItems()
Returns a readonly list of all descending Treeitem (children's children and so on).

Note: the performance of the size method of returned collection is no good.

Specified by:
getItems in interface Tree

getItemCount

public int getItemCount()
Returns the number of child Treeitem. The same as getItems().size().

Note: the performance of this method is no good.

Specified by:
getItemCount in interface Tree

selectItem

public void selectItem(Treeitem item)
Deselects all of the currently selected items and selects the given item.

It is the same as setSelectedItem(org.zkoss.zul.Treeitem).

Parameters:
item - the item to select. If null, all items are deselected.

selectItemApi

public void selectItemApi(Treeitem itemApi)
Deselects all of the currently selected items and selects the given item.

It is the same as setSelectedItem(org.zkoss.zul.Treeitem).

Specified by:
selectItemApi in interface Tree
Parameters:
itemApi - assume as a Treeitem
Since:
3.5.2

addItemToSelection

public void addItemToSelection(Treeitem item)
Selects the given item, without deselecting any other items that are already selected..


addItemToSelectionApi

public void addItemToSelectionApi(Treeitem itemApi)
Selects the given item, without deselecting any other items that are already selected..

Specified by:
addItemToSelectionApi in interface Tree
Parameters:
itemApi - assume as a Treeitem
Since:
3.5.2

removeItemFromSelection

public void removeItemFromSelection(Treeitem item)
Deselects the given item without deselecting other items.


removeItemFromSelectionApi

public void removeItemFromSelectionApi(Treeitem itemApi)
Deselects the given item without deselecting other items.

Specified by:
removeItemFromSelectionApi in interface Tree
Parameters:
itemApi - assume as a Treeitem
Since:
3.5.2

toggleItemSelection

public void toggleItemSelection(Treeitem item)
If the specified item is selected, it is deselected. If it is not selected, it is selected. Other items in the tree that are selected are not affected, and retain their selected state.


toggleItemSelectionApi

public void toggleItemSelectionApi(Treeitem itemApi)
If the specified item is selected, it is deselected. If it is not selected, it is selected. Other items in the tree that are selected are not affected, and retain their selected state.

Specified by:
toggleItemSelectionApi in interface Tree
Parameters:
itemApi - assume as a Treeitem
Since:
3.5.2

clearSelection

public void clearSelection()
Clears the selection.

Specified by:
clearSelection in interface Tree

selectAll

public void selectAll()
Selects all items.

Specified by:
selectAll in interface Tree

getSelectedItem

public Treeitem getSelectedItem()
Returns the selected item.


getSelectedItemApi

public Treeitem getSelectedItemApi()
Returns the selected item.

Specified by:
getSelectedItemApi in interface Tree
Since:
3.5.2

setSelectedItem

public void setSelectedItem(Treeitem item)
Deselects all of the currently selected items and selects the given item.

It is the same as selectItem(org.zkoss.zul.Treeitem).


setSelectedItemApi

public void setSelectedItemApi(Treeitem itemApi)
Deselects all of the currently selected items and selects the given item.

It is the same as selectItem(org.zkoss.zul.Treeitem).

Specified by:
setSelectedItemApi in interface Tree
Parameters:
itemApi - assume as a Treeitem
Since:
3.5.2

getSelectedItems

public java.util.Set getSelectedItems()
Returns all selected items.

Specified by:
getSelectedItems in interface Tree

getSelectedCount

public int getSelectedCount()
Returns the number of items being selected.

Specified by:
getSelectedCount in interface Tree

clear

public void clear()
Clears all child tree items (Treeitem.

Note: after clear, getTreechildren() won't be null, but it has no child

Specified by:
clear in interface Tree

getZclass

public java.lang.String getZclass()
Description copied from class: HtmlBasedComponent
Returns the ZK Cascading Style class(es) for this component. It usually depends on the implementation of the mold (@{link #getMold}).

Default: null (the default value depends on element).

HtmlBasedComponent.setZclass(java.lang.String)) will completely replace the default style of a component. In other words, the default style of a component is associated with the default value of HtmlBasedComponent.getZclass(). Once it is changed, the default style won't be applied at all. If you want to perform small adjustments, use HtmlBasedComponent.setSclass(java.lang.String) instead.

Specified by:
getZclass in interface HtmlBasedComponent
Overrides:
getZclass in class HtmlBasedComponent
See Also:
HtmlBasedComponent.getSclass()

smartUpdate

protected void smartUpdate(java.lang.String attr,
                           java.lang.Object value)
Description copied from class: AbstractComponent
Smart-updates a property of the peer widget associated with the component, running at the client, with the specified value.

The second invocation with the same property will replace the previous call. In other words, the same property will be set only once in each execution.

This method has no effect if AbstractComponent.invalidate() is ever invoked (in the same execution), since AbstractComponent.invalidate() assumes the whole content shall be redrawn and all smart updates to this components can be ignored,

Once AbstractComponent.invalidate() is called, all invocations to AbstractComponent.smartUpdate(java.lang.String, java.lang.Object) will then be ignored, and AbstractComponent.redraw(java.io.Writer) will be invoked later.

It can be called only in the request-processing and event-processing phases; excluding the redrawing phase.

There are two ways to draw a component, one is to invoke Component.invalidate(), and the other is AbstractComponent.smartUpdate(java.lang.String, java.lang.Object). While Component.invalidate() causes the whole content to redraw, AbstractComponent.smartUpdate(java.lang.String, java.lang.Object) let component developer control which part to redraw.

Overrides:
smartUpdate in class AbstractComponent
value - the new value. If it is DeferredValue, the value will be retrieved (by calling DeferredValue.getValue()) in the rendering phase. It is useful if the value can not be determined now.

For some old application servers (example, Webshpere 5.1), Execution.encodeURL(java.lang.String) cannot be called in the event processing thread. So, the developers have to use DeferredValue or disable the use of the event processing thread (by use of disable-event-thread in zk.xml).

In addition, the value can be any kind of objects that the client accepts (marshaled by JSON).

See Also:
AbstractComponent.updateByClient(java.lang.String, java.lang.Object)

beforeChildAdded

public void beforeChildAdded(Component newChild,
                             Component refChild)
Description copied from class: AbstractComponent
Default: does nothing.

Specified by:
beforeChildAdded in interface ComponentCtrl
Overrides:
beforeChildAdded in class AbstractComponent
Parameters:
newChild - the child to be added (never null).
refChild - another child component that the new child will be inserted before it. If null, the new child will be the last child.
See Also:
ComponentCtrl.beforeChildAdded(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component)

insertBefore

public boolean insertBefore(Component newChild,
                            Component refChild)
Description copied from interface: Component
Inserts a child before the reference child.

You could use Component.setParent(org.zkoss.zk.ui.Component) or Component.appendChild(org.zkoss.zk.ui.Component) instead of this method, unless you want to control where to put the child.

Note: Component.setParent(org.zkoss.zk.ui.Component) always calls back Component.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component) and/or Component.removeChild(org.zkoss.zk.ui.Component), while Component.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component) and Component.removeChild(org.zkoss.zk.ui.Component) always calls back Component.setParent(org.zkoss.zk.ui.Component), if the parent is changed. Thus, you don't need to override both Component.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component) and Component.setParent(org.zkoss.zk.ui.Component), if you want to customize the behavior.

Specified by:
insertBefore in interface Component
Overrides:
insertBefore in class AbstractComponent
Parameters:
newChild - the new child to be inserted.
refChild - the child before which you want the new child being inserted. If null, the new child is append to the end.
Returns:
true if newChild is added successfully or moved; false if it already has the specified child and the order doesn't change.

onChildAdded

public void onChildAdded(Component child)
Description copied from class: AbstractComponent
Default: does nothing.

Specified by:
onChildAdded in interface ComponentCtrl
Overrides:
onChildAdded in class AbstractComponent
See Also:
ComponentCtrl.onChildAdded(org.zkoss.zk.ui.Component)

onChildRemoved

public void onChildRemoved(Component child)
Description copied from class: AbstractComponent
Default: does nothing.

Specified by:
onChildRemoved in interface ComponentCtrl
Overrides:
onChildRemoved in class AbstractComponent
See Also:
ComponentCtrl.onChildRemoved(org.zkoss.zk.ui.Component)

clone

public java.lang.Object clone()
Description copied from interface: Component
Clones the component. All of its children is cloned. Notice that the cloned component doesn't belong to any page, nor desktop. It doesn't have parent, either.

Specified by:
clone in interface Component
Overrides:
clone in class AbstractComponent

getChildByNode

protected Component getChildByNode(java.lang.Object node)
Return the Tree or Treeitem component by a given associated node in model.
This implmentation calls TreeModel.getPath(java.lang.Object, java.lang.Object) method to locate assoicated Treeitem (or Tree) via path. You can override this method to speed up performance if possible. Return null, if the Tree or Treeitem is not yet rendered.

Author: jeffliu

Since:
3.0.0

setModel

public void setModel(TreeModel model)
Sets the tree model associated with this tree.

Note: changing a render will not cause the tree to re-render. If you want it to re-render, you could assign the same model again (i.e., setModel(getModel())), or fire an TreeDataEvent event.

Author: jeffliu

Specified by:
setModel in interface Tree
Parameters:
model - the tree model to associate, or null to dis-associate any previous model.
Throws:
UiException - if failed to initialize with the model
Since:
3.0.0

getModel

public TreeModel getModel()
Returns the list model associated with this tree, or null if this tree is not associated with any tree data model.

Author: jeffliu

Specified by:
getModel in interface Tree
Returns:
the list model associated with this tree
Since:
3.0.0

setTreeitemRenderer

public void setTreeitemRenderer(TreeitemRenderer renderer)
Sets the renderer which is used to render each item if getModel() is not null.

Note: changing a render will not cause the tree to re-render. If you want it to re-render, you could assign the same model again (i.e., setModel(getModel())), or fire an TreeDataEvent event.

Author: jeffliu

Specified by:
setTreeitemRenderer in interface Tree
Parameters:
renderer - the renderer, or null to use the default.
Throws:
UiException - if failed to initialize with the model
Since:
3.0.0

getTreeitemRenderer

public TreeitemRenderer getTreeitemRenderer()
Returns the renderer to render each item, or null if the default renderer is used.

Specified by:
getTreeitemRenderer in interface Tree
Returns:
the renderer to render each item, or null if the default
Since:
3.0.0

renderItem

public void renderItem(Treeitem item)
Renders the specified Treeitem, if not loaded yet, with getTreeitemRenderer().

It does nothing if getModel() returns null.

To unload treeitem, use Treeitem.unload().

Since:
3.0.0
See Also:
renderItems(java.util.Set)

renderItemApi

public void renderItemApi(Treeitem itemApi)
Renders the specified Treeitem, if not loaded yet, with getTreeitemRenderer().

It does nothing if getModel() returns null.

To unload treeitem, use Treeitem.unload().

Specified by:
renderItemApi in interface Tree
Parameters:
itemApi - assume as a Treeitem
Since:
3.5.2
See Also:
renderItems(java.util.Set)

renderItem

public void renderItem(Treeitem item,
                       java.lang.Object node)
Renders the specified Treeitem, if not loaded yet, with getTreeitemRenderer().

It does nothing if getModel() returns null.

Note: Since the corresponding node is given, This method has better performance than renderItem(Treeitem item) due to not searching for its corresponding node.

To unload treeitem, use Treeitem.unload().

Since:
3.0.0
See Also:
renderItems(java.util.Set)

renderItemApi

public void renderItemApi(Treeitem itemApi,
                          java.lang.Object node)
Renders the specified Treeitem, if not loaded yet, with getTreeitemRenderer().

It does nothing if getModel() returns null.

Note: Since the corresponding node is given, This method has better performance than renderItem(Treeitem item) due to not searching for its corresponding node.

To unload treeitem, use Treeitem.unload().

Specified by:
renderItemApi in interface Tree
Parameters:
itemApi - assume as a Treeitem
Since:
3.5.2
See Also:
renderItems(java.util.Set)

renderItems

public void renderItems(java.util.Set items)
Renders the specified Treeitem if not loaded yet, with getTreeitemRenderer().

It does nothing if getModel() returns null.

To unload treeitem, with Treeitem.unload().

Specified by:
renderItems in interface Tree
Since:
3.0.0
See Also:
renderItem(org.zkoss.zul.Treeitem)

getAssociatedNode

protected java.lang.Object getAssociatedNode(Treeitem ti,
                                             Tree t)
Return a node which is an associated Treeitem ti in a Tree tree

Since:
3.0.0

renderItemByPath

public Treeitem renderItemByPath(int[] path)
Load treeitems through path path
Note: By using this method, all treeitems in path will be rendered and opened (Treeitem.setOpen(boolean)). If you want to visit the rendered item in paging mold, please invoke setActivePage(Treeitem).

Parameters:
path - - an int[] path, see TreeModel.getPath(java.lang.Object, java.lang.Object)
Returns:
the treeitem from tree by given path
Since:
3.0.0

renderItemByPathApi

public Treeitem renderItemByPathApi(int[] path)
Load treeitems through path path
Note: By using this method, all treeitems in path will be rendered and opened (Treeitem.setOpen(boolean)). If you want to visit the rendered item in paging mold, please invoke setActivePage(Treeitem).

Specified by:
renderItemByPathApi in interface Tree
Parameters:
path - - an int[] path, see TreeModel.getPath(java.lang.Object, java.lang.Object)
Returns:
the treeitem from tree by given path
Since:
3.5.2

redrawChildren

protected void redrawChildren(java.io.Writer out)
                       throws java.io.IOException
Description copied from class: AbstractComponent
Redraws childrens (and then recursively descandants).

Default: it invokes AbstractComponent.redraw(java.io.Writer) for all its children.

If a derived class renders only a subset of its children (such as paging/cropping), it could override AbstractComponent.redrawChildren(java.io.Writer).

Overrides:
redrawChildren in class AbstractComponent
Throws:
java.io.IOException
See Also:
AbstractComponent.redraw(java.io.Writer)

renderProperties

protected void renderProperties(ContentRenderer renderer)
                         throws java.io.IOException
Description copied from class: HtmlBasedComponent
Renders the content of this component, excluding the enclosing tags and children.

See also Render Special Properties

Overrides:
renderProperties in class XulElement
Throws:
java.io.IOException

service

public void service(AuRequest request,
                    boolean everError)
Processes an AU request.

Default: in addition to what are handled by HtmlBasedComponent.service(org.zkoss.zk.au.AuRequest, boolean), it also handles onSelect.

Specified by:
service in interface ComponentCtrl
Overrides:
service in class HtmlBasedComponent
everError - whether any error ever occured before processing this request.
Since:
5.0.0
See Also:
AbstractComponent.setAuService(org.zkoss.zk.au.AuService)


Copyright © 2005-2009 Potix Corporation. All Rights Reserved. SourceForge.net Logo