Class Tree
- java.lang.Object
-
- org.zkoss.zk.ui.AbstractComponent
-
- org.zkoss.zk.ui.HtmlBasedComponent
-
- org.zkoss.zul.impl.XulElement
-
- org.zkoss.zul.impl.MeshElement
-
- org.zkoss.zul.Tree
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,org.zkoss.zk.ui.Component,org.zkoss.zk.ui.ext.Scope,org.zkoss.zk.ui.sys.ComponentCtrl,Paginated
public class Tree extends MeshElement
A container which can be used to hold a tabular or hierarchical set of rows of elements.Event:
SelectEventis sent when user changes the selection.- onAfterRender is sent when the model's data has been rendered.(since 5.0.4)
Default
getZclass(): z-tree. (since 3.5.0)Custom Attributes:
- org.zkoss.zul.tree.rightSelect
- Specifies whether the selection shall be toggled when user right clicks on
item, if the checkmark (
isCheckmark()) is enabled. Notice that you could specify this attribute in any of its ancestor's attributes. It will be inherited. - org.zkoss.zul.tree.autoSort .(since 5.0.7)
- Specifies whether to sort the model when the following cases:
setModel(org.zkoss.zul.TreeModel<?>)is called andTreecol.setSortDirection(java.lang.String)is set.Treecol.setSortDirection(java.lang.String)is called.- Model receives
TreeDataEventandTreecol.setSortDirection(java.lang.String)is set.
TreeDataEvent, you can specifies the value as "ignore.change". Notice that you could specify this attribute in any of its ancestor's attributes. It will be inherited.
[Since 6.0.0]To retrieve what are selected in Tree with a
TreeSelectableModel, you shall useTreeSelectableModel.isPathSelected(int[])to check whether the current path is selected inTreeSelectableModelrather than usinggetSelectedItems(). That is, you shall operate on the item of theTreeSelectableModelrather than on theTreeitemof theTreeif you use theTreeSelectableModelandTreeModel.TreeSelectableModel selModel = ((TreeSelectableModel)getModel()); int[][] paths = selModel.getSelectionPaths(); List<E> selected = new ArrayList<E>(); AbstractTreeModel model = (AbstractTreeModel) selModel; for (int i = 0; i < paths.length; i++) { selected.add(model.getChild(paths[i])); }
[Since 6.0.0]If the TreeModel in Tree implements a
TreeSelectableModel, the multiple selections status is applied from the method ofTreeSelectableModel.isMultiple()DefaultTreeModel selModel = new DefaultTreeModel(treeNode); selModel.setMultiple(true); tree.setModel(selModel);
[Since 6.0.0]To retrieve what are opened nodes in Tree with a
TreeOpenableModel, you shall useTreeOpenableModel.isPathOpened(int[])to check whether the current path is opened inTreeOpenableModelrather than usingTreeitem.isOpen(). That is, you shall operate on the item of theTreeOpenableModelrather than on theTreeitemof theTreeif you use theTreeOpenableModelandTreeModel.TreeOpenableModel openModel = ((TreeOpenableModel)getModel()); int[][] paths = openModel.getOpenPaths(); List<E> opened = new ArrayList<E>(); AbstractTreeModel model = (AbstractTreeModel) openModel; for (int i = 0; i < paths.length; i++) { opened.add(model.getChild(paths[i])); }- org.zkoss.zul.tree.selectOnHighlight.disabled
.(since 7.0.4)- Sets whether to disable select functionality when highlighting text content with mouse dragging or not.
[Since 7.0.0] (EE version only)- org.zkoss.zul.tree.initRodSize
.- Specifies the number of items rendered when the Tree first render.
- org.zkoss.zul.tree.maxRodPageSize
.- Specifies how many pages (of treeitems) to keep rendered in memory (on the server side) when navigating the tree using pagination. (Paging mold only)
- org.zkoss.zul.tree.preloadSize
.- Specifies the number of items to preload when receiving the rendering request from the client.
It is used only if live data (
setModel(TreeModel)and not paging (getPagingChild()).- Author:
- tomyeh
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.zkoss.zul.impl.MeshElement
MeshElement.InternalPaging
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_THROTTLE_MILLIS-
Fields inherited from class org.zkoss.zul.impl.MeshElement
CSS_FLEX_AUTO_DISABLED_COUNT
-
-
Constructor Summary
Constructors Constructor Description Tree()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddItemToSelection(Treeitem item)Selects the given item, without deselecting any other items that are already selected..voidbeforeChildAdded(org.zkoss.zk.ui.Component newChild, org.zkoss.zk.ui.Component refChild)voidclear()Clears all child tree items (Treeitem.voidclearSelection()Clears the selection.java.lang.Objectclone()intgetActivePage()Returns the active page (starting from 0).protected java.lang.ObjectgetAssociatedNode(Treeitem ti, Tree t)Return a node which is an associated Treeitem ti in a Tree treeprotected org.zkoss.zk.ui.ComponentgetChildByNode(java.lang.Object node)Return the Tree or Treeitem component by a given associated node in model, or null if the treeitem is not instantiated (i.e., rendered) yet.protected org.zkoss.zk.ui.ComponentgetChildByPath(int[] path)Return the Tree or Treeitem component by a path, or null if corresponding Treeitem is not instantiated (i.e., rendered) yet.FrozengetFrozen()Returns the frozen child.java.util.Collection<org.zkoss.zk.ui.Component>getHeads()Returns a collection of heads, includinggetTreecols()and auxiliary heads (Auxhead) (never null).java.lang.StringgetInnerWidth()Returns the inner width of this component.intgetItemCount()Returns the number of childTreeitem.<T> TreeitemRenderer<T>getItemRenderer()Returns the renderer to render each item, or null if the default renderer is used.java.util.Collection<Treeitem>getItems()Returns a readonly list of all descendingTreeitem(children's children and so on).<T> TreeModel<T>getModel()Returns the list model associated with this tree, or null if this tree is not associated with any tree data model.java.lang.StringgetName()Returns the name of this component.java.lang.StringgetNonselectableTags()Returns a list of HTML tag names that shall not cause the tree item being selected if they are clicked.intgetPageSize()Returns the page size, a.k.a., the number items per page.PaginalgetPaginal()Returns the paging controller, or null if not available.PaginggetPagingChild()Returns the child paging controller that is created automatically, or null if mold is not "paging", or the controller is specified externally bysetPaginal(org.zkoss.zul.ext.Paginal).org.zkoss.zk.ui.sys.PropertyAccessgetPropertyAccess(java.lang.String prop)intgetRows()Returns the rows.intgetSelectedCount()Returns the number of items being selected.TreeitemgetSelectedItem()Returns the selected item.java.util.Set<Treeitem>getSelectedItems()Returns all selected items.java.lang.StringgetSeltype()Returns the seltype.TreechildrengetTreechildren()Returns the treechildren that this tree owns (might null).TreecolsgetTreecols()Returns the treecols that this tree owns (might null).TreefootgetTreefoot()Returns the treefoot that this tree owns (might null).java.lang.StringgetZclass()booleaninsertBefore(org.zkoss.zk.ui.Component newChild, org.zkoss.zk.ui.Component refChild)protected booleanisAutohidePaging()booleanisCheckmark()Returns whether the check mark shall be displayed in front of each item.booleanisMultiple()Returns whether multiple selections are allowed.protected booleanisSelectOnHighlightDisabled()booleanisVflex()Returns whether to grow and shrink vertical to fit their given space, so called vertical flexibility.voidonAfterRender()voidonChildAdded(org.zkoss.zk.ui.Component child)voidonChildRemoved(org.zkoss.zk.ui.Component child)voidonInitRender()Handles a private event, onInitRender.voidonPageAttached(org.zkoss.zk.ui.Page newpage, org.zkoss.zk.ui.Page oldpage)voidonPageDetached(org.zkoss.zk.ui.Page page)protected Paginalpgi()Returns the instance of the @{link Paginal}protected voidredrawChildren(java.io.Writer out)voidremoveItemFromSelection(Treeitem item)Deselects the given item without deselecting other items.voidrenderItem(Treeitem item)Renders the specifiedTreeitem, if not loaded yet, withgetItemRenderer().voidrenderItem(Treeitem item, java.lang.Object node)Renders the specifiedTreeitem, if not loaded yet, withgetItemRenderer().TreeitemrenderItemByNode(java.lang.Object node)Load the treeitems by the given node.TreeitemrenderItemByPath(int[] path)Load the treeitems by giving a path of the treeitems top open.voidrenderItems(java.util.Set<? extends Treeitem> items)Renders the specifiedTreeitemif not loaded yet, withgetItemRenderer().protected voidrenderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer)voidselectAll()Selects all items.voidselectItem(Treeitem item)Deselects all of the currently selected items and selects the given item.voidservice(org.zkoss.zk.au.AuRequest request, boolean everError)Processes an AU request.voidsessionDidActivate(org.zkoss.zk.ui.Page page)voidsessionWillPassivate(org.zkoss.zk.ui.Page page)voidsetActivePage(int pg)Sets the active page (starting from 0).voidsetActivePage(Treeitem item)Sets the active page in which the specified item is.voidsetCheckmark(boolean checkmark)Sets whether the check mark shall be displayed in front of each item.voidsetHeight(java.lang.String height)voidsetInnerWidth(java.lang.String innerWidth)Sets the inner width of this component.voidsetItemRenderer(java.lang.String clsnm)Sets the renderer by use of a class name.voidsetItemRenderer(TreeitemRenderer<?> renderer)Sets the renderer which is used to render each item ifgetModel()is not null.voidsetModel(TreeModel<?> model)Sets the tree model associated with this tree.voidsetMold(java.lang.String mold)Sets the mold to render this component.voidsetMultiple(boolean multiple)Sets whether multiple selections are allowed.voidsetName(java.lang.String name)Sets the name of this component.voidsetNonselectableTags(java.lang.String tags)Sets a list of HTML tag names that shall not cause the tree item being selected if they are clicked.voidsetPageSize(int pgsz)Sets the page size, a.k.a., the number items per page.voidsetPaginal(Paginal pgi)voidsetRows(int rows)Sets the rows.voidsetSelectedItem(Treeitem item)Deselects all of the currently selected items and selects the given item.voidsetSeltype(java.lang.String seltype)Sets the seltype.voidsetVflex(boolean vflex)Sets whether to grow and shrink vertical to fit their given space, so called vertical flexibility.voidsetVflex(java.lang.String flex)voidsmartUpdate(java.lang.String attr, java.lang.Object value)voidtoggleItemSelection(Treeitem item)If the specified item is selected, it is deselected.-
Methods inherited from class org.zkoss.zul.impl.MeshElement
checkBeforeSetRows, evalCSSFlex, getPageCount, getPagingPosition, getSpan, isAutopaging, isPagingDisabled, isSizedByContent, isSpan, setAutopaging, setPagingDisabled, setPagingPosition, setSizedByContent, setSpan, setSpan
-
Methods inherited from class org.zkoss.zul.impl.XulElement
getContext, getCtrlKeys, getPopup, getTooltip, setContext, setContext, setContextAttributes, setCtrlKeys, setPopup, setPopup, setPopupAttributes, setTooltip, setTooltip, setTooltipAttributes
-
Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
addSclass, focus, getAction, getClientAction, getDraggable, getDroppable, getExtraCtrl, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getStyle, getTabindex, getTabindexInteger, getTooltiptext, getTop, getVflex, getWidth, getZindex, getZIndex, removeSclass, removeSclass, setAction, setClass, setClientAction, setDraggable, setDroppable, setFocus, setHeight0, setHeightDirectly, setHflex, setHflex0, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, setStyle, setTabindex, setTabindex, setTooltiptext, setTop, setTopDirectly, setVflex0, setVflexDirectly, setWidth, setWidth0, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectly
-
Methods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addCallback, addClientEvent, addEventHandler, addEventListener, addEventListener, addForward, addForward, addForward, addForward, addMoved, addRedrawCallback, addScopeListener, addShadowRoot, addShadowRootBefore, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildRemoved, beforeParentChanged, destroyIndexCacheMap, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableBindingAnnotation, disableClientUpdate, disableHostChanged, enableBindingAnnotation, enableHostChanged, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getAutag, getCallback, getChildren, getClientAttribute, getClientDataAttribute, getClientEvents, getDefaultMold, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getEventListenerMap, getEventListeners, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getForwards, getId, getIndexCacheMap, getLastChild, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getRedrawCallback, getRoot, getShadowFellowIfAny, getShadowRoots, getShadowVariable, getShadowVariable, getShadowVariable0, getSpaceOwner, getSpecialRendererOutput, getStubonly, getSubBindingAnnotationCount, getTemplate, getTemplateNames, getUuid, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasBindingAnnotation, hasFellow, hasFellow, hasSubBindingAnnotation, initIndexCacheMap, invalidate, isChildable, isDisabledHostChanged, isInitialized, isInvalidated, isListenerAvailable, isVisible, onParentChanged, onWrongValue, query, queryAll, redraw, removeAttribute, removeAttribute, removeAttribute, removeCallback, removeChild, removeEventListener, removeForward, removeForward, removeRedrawCallback, removeScopeListener, removeShadowRoot, render, render, render, renderPropertiesOnly, replace, response, response, response, service, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setClientAttribute, setClientDataAttribute, setDefinition, setDefinition, setId, setPage, setPageBefore, setParent, setStubonly, setStubonly, setSubBindingAnnotationCount, setTemplate, setVisible, setVisibleDirectly, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateByClient, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerialize
-
-
-
-
Field Detail
-
DEFAULT_THROTTLE_MILLIS
public static final int DEFAULT_THROTTLE_MILLIS
- See Also:
- Constant Field Values
-
-
Method Detail
-
onPageAttached
public void onPageAttached(org.zkoss.zk.ui.Page newpage, org.zkoss.zk.ui.Page oldpage)- Specified by:
onPageAttachedin interfaceorg.zkoss.zk.ui.sys.ComponentCtrl- Overrides:
onPageAttachedin classorg.zkoss.zk.ui.AbstractComponent
-
onPageDetached
public void onPageDetached(org.zkoss.zk.ui.Page page)
- Specified by:
onPageDetachedin interfaceorg.zkoss.zk.ui.sys.ComponentCtrl- Overrides:
onPageDetachedin classorg.zkoss.zk.ui.AbstractComponent
-
setMold
public void setMold(java.lang.String mold)
Sets the mold to render this component.- Specified by:
setMoldin interfaceorg.zkoss.zk.ui.Component- Overrides:
setMoldin classorg.zkoss.zk.ui.AbstractComponent- Parameters:
mold- the mold. If null or empty, "default" is assumed. Allowed values: default, paging- See Also:
ComponentDefinition
-
getPaginal
public Paginal getPaginal()
Returns the paging controller, or null if not available. Note: the paging controller is used only ifAbstractComponent.getMold()is "paging".If mold is "paging", this method never returns null, because a child paging controller is created automatically (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 bysetMold(java.lang.String)with "paging"), the tree will rely on the paging controller to handle long-content instead of scrolling.- Since:
- 3.0.7
-
setPaginal
public void setPaginal(Paginal pgi)
-
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 bysetPaginal(org.zkoss.zul.ext.Paginal).- Since:
- 3.0.7
-
getPageSize
public int getPageSize()
Returns the page size, a.k.a., the number items per page.- Overrides:
getPageSizein classMeshElement- Throws:
java.lang.IllegalStateException- ifgetPaginal()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 org.zkoss.zk.ui.WrongValueExceptionSets the page size, a.k.a., the number items per page.Note: mold is "paging" and no external controller is specified.
- Overrides:
setPageSizein classMeshElement- Throws:
org.zkoss.zk.ui.WrongValueException- Since:
- 2.4.1
-
pgi
protected Paginal pgi()
Description copied from class:MeshElementReturns the instance of the @{link Paginal}- Specified by:
pgiin classMeshElement
-
getTreecols
public Treecols getTreecols()
Returns the treecols that this tree owns (might null).
-
getTreefoot
public Treefoot getTreefoot()
Returns the treefoot that this tree owns (might null).
-
getFrozen
public Frozen getFrozen()
Returns the frozen child.- Since:
- 7.0.0
-
getTreechildren
public Treechildren getTreechildren()
Returns the treechildren that this tree owns (might null).
-
getHeads
public java.util.Collection<org.zkoss.zk.ui.Component> getHeads()
Returns a collection of heads, includinggetTreecols()and auxiliary heads (Auxhead) (never null).- Since:
- 3.0.0
-
getRows
public int getRows()
Returns the rows. Zero means no limitation.Default: 0.
-
setRows
public void setRows(int rows) throws org.zkoss.zk.ui.WrongValueExceptionSets the rows.Note: Not allowed to set rows and height/vflex at the same time
- Throws:
org.zkoss.zk.ui.WrongValueException
-
setHeight
public void setHeight(java.lang.String height)
- Overrides:
setHeightin classorg.zkoss.zk.ui.HtmlBasedComponent
-
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.
-
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.
- Parameters:
name- the name of this component.
-
setNonselectableTags
public void setNonselectableTags(java.lang.String tags)
Sets a list of HTML tag names that shall not cause the tree item being selected if they are clicked.Default: null (it means button, input, textarea and a). If you want to select no matter which tag is clicked, please specify an empty string.
- Parameters:
tags- a list of HTML tag names that will not cause the tree item being selected if clicked. Specify null to use the default and "" to indicate none.- Since:
- 5.0.5
-
getNonselectableTags
public java.lang.String getNonselectableTags()
Returns a list of HTML tag names that shall not cause the tree item being selected if they are clicked.Refer to
setNonselectableTags(java.lang.String)for details.- Since:
- 5.0.5
-
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 ifisMultiple()returns false.
-
isVflex
public boolean isVflex()
Returns whether to grow and shrink vertical to fit their given space, so called vertical flexibility.Note: this attribute is ignored if
setRows(int)is specifiedDefault: false.
-
setVflex
public void setVflex(boolean vflex)
Sets whether to grow and shrink vertical to fit their given space, so called vertical flexibility.Note: this attribute is ignored if
setRows(int)is specified
-
setVflex
public void setVflex(java.lang.String flex)
- Overrides:
setVflexin classorg.zkoss.zk.ui.HtmlBasedComponent
-
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.- 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%"
- Since:
- 3.0.0
- See Also:
setInnerWidth(java.lang.String)
-
getSeltype
public java.lang.String getSeltype()
Returns the seltype.Default: "single".
-
setSeltype
public void setSeltype(java.lang.String seltype) throws org.zkoss.zk.ui.WrongValueExceptionSets the seltype. "single","multiple" is supported.- Throws:
org.zkoss.zk.ui.WrongValueException
-
isMultiple
public boolean isMultiple()
Returns whether multiple selections are allowed.Default: false.
-
setMultiple
public void setMultiple(boolean multiple)
Sets whether multiple selections are allowed.Notice that, if a model is assigned, it will change the model's state (by
TreeSelectableModel.setMultiple(boolean)).
-
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
-
setActivePage
public void setActivePage(int pg) throws org.zkoss.zk.ui.WrongValueExceptionDescription copied from class:MeshElementSets the active page (starting from 0).- Overrides:
setActivePagein classMeshElement- Throws:
org.zkoss.zk.ui.WrongValueException
-
smartUpdate
public void smartUpdate(java.lang.String attr, java.lang.Object value)- Overrides:
smartUpdatein classorg.zkoss.zk.ui.AbstractComponent
-
getItems
public java.util.Collection<Treeitem> getItems()
Returns a readonly list of all descendingTreeitem(children's children and so on).Note: the performance of the size method of returned collection is no good.
-
getItemCount
public int getItemCount()
Returns the number of childTreeitem. The same asgetItems().size().Note: the performance of this method is no good.
-
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.
-
addItemToSelection
public void addItemToSelection(Treeitem item)
Selects the given item, without deselecting any other items that are already selected..
-
removeItemFromSelection
public void removeItemFromSelection(Treeitem item)
Deselects the given item without deselecting other items.
-
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.
-
clearSelection
public void clearSelection()
Clears the selection.
-
selectAll
public void selectAll()
Selects all items.
-
getSelectedItem
public Treeitem getSelectedItem()
Returns the selected item.
-
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).
-
getSelectedItems
public java.util.Set<Treeitem> getSelectedItems()
Returns all selected items.
-
getSelectedCount
public int getSelectedCount()
Returns the number of items being selected.
-
clear
public void clear()
Clears all child tree items (Treeitem.Note: after clear,
getTreechildren()won't be null, but it has no child
-
getZclass
public java.lang.String getZclass()
- Overrides:
getZclassin classorg.zkoss.zk.ui.HtmlBasedComponent
-
beforeChildAdded
public void beforeChildAdded(org.zkoss.zk.ui.Component newChild, org.zkoss.zk.ui.Component refChild)- Specified by:
beforeChildAddedin interfaceorg.zkoss.zk.ui.sys.ComponentCtrl- Overrides:
beforeChildAddedin classorg.zkoss.zk.ui.AbstractComponent
-
insertBefore
public boolean insertBefore(org.zkoss.zk.ui.Component newChild, org.zkoss.zk.ui.Component refChild)- Specified by:
insertBeforein interfaceorg.zkoss.zk.ui.Component- Overrides:
insertBeforein classorg.zkoss.zk.ui.AbstractComponent
-
onChildAdded
public void onChildAdded(org.zkoss.zk.ui.Component child)
- Specified by:
onChildAddedin interfaceorg.zkoss.zk.ui.sys.ComponentCtrl- Overrides:
onChildAddedin classorg.zkoss.zk.ui.AbstractComponent
-
onChildRemoved
public void onChildRemoved(org.zkoss.zk.ui.Component child)
- Specified by:
onChildRemovedin interfaceorg.zkoss.zk.ui.sys.ComponentCtrl- Overrides:
onChildRemovedin classorg.zkoss.zk.ui.AbstractComponent
-
clone
public java.lang.Object clone()
- Specified by:
clonein interfaceorg.zkoss.zk.ui.Component- Overrides:
clonein classXulElement
-
sessionWillPassivate
public void sessionWillPassivate(org.zkoss.zk.ui.Page page)
- Specified by:
sessionWillPassivatein interfaceorg.zkoss.zk.ui.sys.ComponentCtrl- Overrides:
sessionWillPassivatein classorg.zkoss.zk.ui.AbstractComponent
-
sessionDidActivate
public void sessionDidActivate(org.zkoss.zk.ui.Page page)
- Specified by:
sessionDidActivatein interfaceorg.zkoss.zk.ui.sys.ComponentCtrl- Overrides:
sessionDidActivatein classorg.zkoss.zk.ui.AbstractComponent
-
getChildByNode
protected org.zkoss.zk.ui.Component getChildByNode(java.lang.Object node)
Return the Tree or Treeitem component by a given associated node in model, or null if the treeitem is not instantiated (i.e., rendered) yet. It returns this tree if the given node is the root node (i.e.,TreeModel.getRoot()).- Throws:
java.lang.IllegalStateException- if no model is assigned (setModel(org.zkoss.zul.TreeModel<?>)).- Since:
- 3.0.0
- See Also:
renderItemByNode(java.lang.Object)
-
getChildByPath
protected org.zkoss.zk.ui.Component getChildByPath(int[] path)
Return the Tree or Treeitem component by a path, or null if corresponding Treeitem is not instantiated (i.e., rendered) yet. It returns this tree if the given node is the root node. (i.e.,TreeModel.getRoot()).- Since:
- 6.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
TreeDataEventevent.- Parameters:
model- the tree model to associate, or null to dissociate any previous model.- Throws:
org.zkoss.zk.ui.UiException- if failed to initialize with the model- Since:
- 3.0.0
-
onInitRender
public void onInitRender()
Handles a private event, onInitRender. It is used only for implementation, and you rarely need to invoke it explicitly.- Since:
- 6.0.0
-
getModel
public <T> TreeModel<T> getModel()
Returns the list model associated with this tree, or null if this tree is not associated with any tree data model.- Returns:
- the list model associated with this tree
- Since:
- 3.0.0
-
setItemRenderer
public void setItemRenderer(TreeitemRenderer<?> renderer)
Sets the renderer which is used to render each item ifgetModel()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
TreeDataEventevent.- Parameters:
renderer- the renderer, or null to use the default.- Throws:
org.zkoss.zk.ui.UiException- if failed to initialize with the model- Since:
- 5.0.6
-
setItemRenderer
public void setItemRenderer(java.lang.String clsnm) throws java.lang.ClassNotFoundException, java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.reflect.InvocationTargetExceptionSets the renderer by use of a class name. It creates an instance automatically.- Throws:
java.lang.ClassNotFoundExceptionjava.lang.NoSuchMethodExceptionjava.lang.IllegalAccessExceptionjava.lang.InstantiationExceptionjava.lang.reflect.InvocationTargetException- Since:
- 6.5.2
-
getItemRenderer
public <T> TreeitemRenderer<T> getItemRenderer()
Returns the renderer to render each item, or null if the default renderer is used.- Returns:
- the renderer to render each item, or null if the default
- Since:
- 5.0.6
-
renderItem
public void renderItem(Treeitem item)
Renders the specifiedTreeitem, if not loaded yet, withgetItemRenderer().It does nothing if
getModel()returns null.To unload treeitem, use
Treeitem.unload().- Since:
- 3.0.0
- See Also:
renderItems(java.util.Set<? extends org.zkoss.zul.Treeitem>)
-
renderItem
public void renderItem(Treeitem item, java.lang.Object node)
Renders the specifiedTreeitem, if not loaded yet, withgetItemRenderer().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<? extends org.zkoss.zul.Treeitem>)
-
renderItems
public void renderItems(java.util.Set<? extends Treeitem> items)
Renders the specifiedTreeitemif not loaded yet, withgetItemRenderer().It does nothing if
getModel()returns null.To unload treeitem, with
Treeitem.unload().- 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
-
renderItemByNode
public Treeitem renderItemByNode(java.lang.Object node)
Load the treeitems by the given node. This method must be used with a tree model, and the node is one of the value returned byTreeModel.getChild(E, int).Notice that this method has to search the model one-by-one. The performance might not be good, so use
renderItemByPath(int[])if possible.- Returns:
- the treeitem that is associated with the give node, or null no treeitem is associated (including the give node is the root).
- Throws:
java.lang.IllegalStateException- if no model is assigned (setModel(org.zkoss.zul.TreeModel<?>)).- Since:
- 5.0.6, #getChildByNode
-
renderItemByPath
public Treeitem renderItemByPath(int[] path)
Load the treeitems by giving a path of the treeitems top open.
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 invokesetActivePage(Treeitem).- Parameters:
path- - an index path. The first element is the index at the first level of the tree structure.- Returns:
- the treeitem from tree by given path
- Since:
- 3.0.0
-
redrawChildren
protected void redrawChildren(java.io.Writer out) throws java.io.IOException- Overrides:
redrawChildrenin classorg.zkoss.zk.ui.AbstractComponent- Throws:
java.io.IOException
-
renderProperties
protected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) throws java.io.IOException- Overrides:
renderPropertiesin classMeshElement- Throws:
java.io.IOException
-
isAutohidePaging
protected boolean isAutohidePaging()
- Specified by:
isAutohidePagingin classMeshElement
-
isSelectOnHighlightDisabled
protected boolean isSelectOnHighlightDisabled()
-
getPropertyAccess
public org.zkoss.zk.ui.sys.PropertyAccess getPropertyAccess(java.lang.String prop)
- Specified by:
getPropertyAccessin interfaceorg.zkoss.zk.ui.sys.ComponentCtrl- Overrides:
getPropertyAccessin classXulElement
-
service
public void service(org.zkoss.zk.au.AuRequest request, boolean everError)Processes an AU request.Default: in addition to what are handled by
HtmlBasedComponent.service(AuRequest, boolean), it also handles onSelect.- Specified by:
servicein interfaceorg.zkoss.zk.ui.sys.ComponentCtrl- Overrides:
servicein classorg.zkoss.zk.ui.HtmlBasedComponent- Since:
- 5.0.0
-
getActivePage
public int getActivePage()
Description copied from class:MeshElementReturns the active page (starting from 0).- Overrides:
getActivePagein classMeshElement
-
onAfterRender
public void onAfterRender()
-
-