Interface IListbox
- All Superinterfaces:
IAnyGroup<IListbox>,IChildable<IListbox,,IListitemBase> IComponent<IListbox>,IComposite<IListbox,,IMeshComposite> IHtmlBasedComponent<IListbox>,IMeshElement<IListbox>,IXulElement<IListbox>
Listbox component
Note: unlike Listbox, there is no "select" mold in stateless API,
please use ISelectbox instead.
Support @Action
| Name | Action Type |
|---|---|
| onSelect | ActionData: SelectData
Notifies one that the user has selected a new item in the listbox. |
| onFocus | Denotes when a component gets the focus. Remember event listeners
execute at the server, so the focus at the client might be changed when
the event listener for onFocus got executed. |
| onBlur | Denotes when a component loses the focus. Remember event listeners
execute at the server, so the focus at the client might be changed
when the event listener for onBlur got executed. |
| onPageSize | ActionData: PageSizeData
Notifies the paging size has been changed when the autopaging ( iListbox.withAutopaging(boolean)) is enabled and a user changed
the size of the content. |
| onCheckSelectAll | ActionData: CheckData
Notifies the checkbox on a listheader is checked to select all checkable items. |
Support Molds
| Name | Snapshot |
|---|---|
"default" |
![]() |
"paging" |
![]() |
Support Application Library Properties
-
To turn on the auto-sort facility to sort the model for this component, you have to specify
withAutosort(Autosort)toIListbox.Autosort.ENABLEorIListbox.Autosort.IGNORE_CHANGE.Or configure it from zk.xml by setting library properties. For example,
<library-property/> <name>org.zkoss.zul.listbox.autoSort</name/> <value>true</value/> </library-property/> -
To set to prefer to deselect all other items and select the item being clicked when
isCheckmark()is enabled, you have to specifywithCheckmarkDeselectOther(boolean)totrue.Or configure it from zk.xml by setting library properties. For example,
<library-property/> <name>org.zkoss.zul.listbox.checkmarkDeselectOthers</name/> <value>true</value/> </library-property/> -
To set whether to disable select functionality when highlighting text content with mouse dragging or not, you have to specify
withSelectOnHighlightDisabled(boolean)totrue.Or configure it from zk.xml by setting library properties. For example,
<library-property/> <name>org.zkoss.zul.listbox.selectOnHighlight.disabled</name/> <value>true</value/> </library-property/> -
To set whether to disable the selection will be toggled when the user right clicks item, only if
isCheckmark()is enabled. You have to specifywithRightSelect(boolean)tofalse.Or configure it from zk.xml by setting library properties. For example,
<library-property/> <name>org.zkoss.zul.listbox.rightSelect</name/> <value>false</value/> </library-property/> -
To set whether to enable the selection will be toggled when the user clicks listgroup item, only if
IListgroupChildin used. You have to specifywithListgroupSelectable(boolean)totrue.Or configure it from zk.xml by setting library properties. For example,
<library-property/> <name>org.zkoss.zul.listbox.groupSelect</name/> <value>true</value/> </library-property/>
- Author:
- katherine
- See Also:
-
Listbox
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumSpecifies whether to sort the model when the following cases: WithListModelcase andIListheader.withSortDirection(String)is set.IListheader.withSortDirection(String)is called. Model receivesListDataEventandIListheader.withSortDirection(String)is set. If you want to ignore sorting when receiving ListDataEvent, you can specify the value asIListbox.Autosort.IGNORE_CHANGE.static classBuilds instances of typeIListbox.static classBuilds an updater of typeIListboxforUiAgent.smartUpdate(Locator, SmartUpdater).Nested classes/interfaces inherited from interface org.zkoss.stateless.sul.IMeshElement
IMeshElement.PagingPosition -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault StringReturns whether to sort all items when model or sort direction be changed.Returns the auxhead child.Returns the frozen child.default StringReturns the inner width of this component.Returns the foot.Returns the listhead.Returns a list of HTML tag names that shall not cause the tree item being selected if they are clicked.Returns the style class for the odd rows.Returns the responsive policy set on this component, ornullif unset.Returns the responsive columns token string set on this component, used by"stacking"mode, ornullif unset.default intgetRows()Returns the number of the rows to display at screen.default StringReturns the client widget class.default booleanReturns whether the check mark shall be displayed in front of each item.default booleanReturns whether to toggle the selection if clicking on a tree item with a checkmark.default booleanReturns whether Listgroup is selectable.default booleanReturns whether multiple selections are allowed.default booleanReturns whether to toggle a list item selection on right click, only ifisCheckmark()is enabled.default booleanReturns whether to disable select functionality when highlighting text content with mouse dragging or not.static IListboxof(Iterable<? extends IListitemBase> children) Returns the instance with the givenIListitemBasechildren.static IListboxof(IListitemBase... children) Returns the instance with the givenIListitemBasechildren.static IListboxReturns the instance with the given id.static IListboxofListfoot(IListfoot foot) Returns the instance with the givenIListfootfoot child.static IListboxofListfooters(Iterable<? extends IListfooter<IAnyGroup>> children) Returns the instance with the givenIListfooterfooter children.static IListboxofListfooters(IListfooter<IAnyGroup>... children) Returns the instance with the givenIListfooterfooter children.static IListboxofListhead(IListhead listhead) Returns the instance with the givenIListheadchild.static IListboxofListheaders(Iterable<? extends IListheader<IAnyGroup>> children) Returns the instance with the givenIListheadercolumn children.static IListboxofListheaders(IListheader<IAnyGroup>... children) Returns the instance with the givenIListheadercolumn children.default IListboxwithAllComponents(Iterable<? extends IMeshComposite> elements) Copy the current immutable object with elements that replace the content ofchildren.withAutosort(String autosort) Returns a copy ofthisimmutable component with the specifiedautosort.default IListboxwithAutosort(IListbox.Autosort autosort) Returns a copy ofthisimmutable component with the specifiedautosort.withAuxhead(Iterable<? extends IAuxhead> auxhead) Returns a copy ofthisimmutable component with the specifiedauxhead.default IListboxwithAuxhead(IAuxhead... auxhead) Returns a copy ofthisimmutable component with the specifiedauxhead.withCheckmark(boolean checkmark) Returns a copy ofthisimmutable component with the specifiedcheckmark.withCheckmarkDeselectOther(boolean checkmarkDeselectOther) Returns a copy ofthisimmutable component with the specifiedcheckmarkDeselectOther.withFrozen(IFrozen frozen) Returns a copy ofthisimmutable component with the specifiedfrozen.withInnerWidth(String innerWidth) Returns a copy ofthisimmutable component with the specifiedinnerWidth.withListfoot(IListfoot listfoot) Returns a copy ofthisimmutable component with the specifiedlistfoot.withListgroupSelectable(boolean listgroupSelectable) Returns a copy ofthisimmutable component with the specifiedlistgroupSelectable.withListhead(IListhead listhead) Returns a copy ofthisimmutable component with the specifiedlisthead.withMultiple(boolean multiple) Returns a copy ofthisimmutable component with the specifiedmultiple.withNonselectableTags(String nonselectableTags) Returns a copy ofthisimmutable component with the specifiedname.withOddRowSclass(String oddRowSclass) Returns a copy ofthisimmutable component with the specifiedoddRowSclass.withResponsive(String responsive) Returns a copy ofthisimmutable component with the specifiedresponsive.withResponsiveColumns(String responsiveColumns) Returns a copy ofthisimmutable component with the specifiedresponsiveColumns.withRightSelect(boolean rightSelect) Returns a copy ofthisimmutable component with the specifiedrightSelect.withRows(int rows) Returns a copy ofthisimmutable component with the specifiedrows.withSelectOnHighlightDisabled(boolean selectOnHighlightDisabled) Returns a copy ofthisimmutable component with the specifiedselectOnHighlightDisabled.Methods inherited from interface org.zkoss.stateless.sul.IChildable
getChildren, withChildren, withChildrenMethods inherited from interface org.zkoss.stateless.sul.IComponent
getAction, getActions, getClientAttributes, getId, getMold, getWidgetListeners, getWidgetOverrides, isVisible, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withActions, withActions, withClientAttribute, withClientAttributes, withId, withMold, withVisible, withWidgetClass, withWidgetListener, withWidgetListeners, withWidgetOverride, withWidgetOverridesMethods inherited from interface org.zkoss.stateless.sul.IHtmlBasedComponent
getClientAction, getDraggable, getDroppable, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getSkeleton, getStyle, getTabindex, getTooltiptext, getTop, getVflex, getWidth, getZclass, getZIndex, isFocus, withClientAction, withDraggable, withDroppable, withFocus, withHeight, withHflex, withLeft, withRenderdefer, withSclass, withSkeleton, withStyle, withTabindex, withTabindex, withTooltiptext, withTop, withVflex, withWidth, withZclass, withZIndexMethods inherited from interface org.zkoss.stateless.sul.IMeshElement
getPagingChild, getPagingPosition, getSpan, isAutopaging, isNativeScrollbar, isSizedByContent, withAutopaging, withNativeScrollbar, withPagingChild, withPagingPosition, withPagingPosition, withSizedByContent, withSpan, withSpanMethods inherited from interface org.zkoss.stateless.sul.IXulElement
getContext, getCtrlKeys, getPopup, getTooltip, withContext, withCtrlKeys, withPopup, withTooltip
-
Field Details
-
DEFAULT
Constant for default attributes of this immutable component. -
PAGING
Constant for"paging"mold attributes of this immutable component.
-
-
Method Details
-
getWidgetClass
Returns the client widget class.Default:
"zul.sel.Listbox"- Specified by:
getWidgetClassin interfaceIComponent<IListbox>
-
getListhead
Returns the listhead.Default:
null -
withListhead
Returns a copy ofthisimmutable component with the specifiedlisthead.Sets the listhead as a child to this component
- Parameters:
listhead- The listhead child.Default:
null.- Returns:
- A modified copy of the
thisobject
-
getListfoot
Returns the foot.Default:
null -
withListfoot
Returns a copy ofthisimmutable component with the specifiedlistfoot.Sets the listfoot as a child to this component
- Parameters:
listfoot- The listfoot child.Default:
null.- Returns:
- A modified copy of the
thisobject
-
getFrozen
Returns the frozen child.Default:
null. -
withFrozen
Returns a copy ofthisimmutable component with the specifiedfrozen.Sets the frozen as a child to this component
- Parameters:
frozen- The foot child.Default:
null.- Returns:
- A modified copy of the
thisobject
-
getAuxhead
Returns the auxhead child. -
withAuxhead
Returns a copy ofthisimmutable component with the specifiedauxhead.Sets the list of auxhead as children to this component
- Parameters:
auxhead- The auxhead children.Default:
null.- Returns:
- A modified copy of the
thisobject
-
withAuxhead
Returns a copy ofthisimmutable component with the specifiedauxhead.Sets the list of auxhead as children to this component
- Parameters:
auxhead- The auxhead child.Default:
null.- Returns:
- A modified copy of the
thisobject
-
withAllComponents
Description copied from interface:ICompositeCopy the current immutable object with elements that replace the content ofchildren. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Specified by:
withAllComponentsin interfaceIComposite<IListbox,IMeshComposite> - Parameters:
elements- An iterable of children elements to set- Returns:
- A modified copy of
thisobject
-
getRows
default int getRows()Returns the number of the rows to display at screen. Zero means no limitation.Default:
0 -
withRows
Returns a copy ofthisimmutable component with the specifiedrows.Sets the number of the rows of the listbox to display at a screen, which means the height of the listbox is based on the calculation of the number of the rows by multiplying with each row height.
Note: Not allowed to setrowsandheight/vflexat the same time.- Parameters:
rows- The number of rows to display.Default:
0. (Meaning no limitation)- Returns:
- A modified copy of the
thisobject
-
getAutosort
Returns whether to sort all items when model or sort direction be changed.Default:
false, if the"org.zkoss.zul.listbox.autoSort"library property is not set in zk.xml.Note: it's meaningless if
ListModelis not set. -
withAutosort
Returns a copy ofthisimmutable component with the specifiedautosort.Sets to enable the auto-sort facility to sort the model for this component. Meaningless if
ListModelis not set.- Parameters:
autosort- The allowed values arenull,"false","true", and"ignore.change".Default:
null.- Returns:
- A modified copy of the
thisobject
-
withAutosort
Returns a copy ofthisimmutable component with the specifiedautosort.Sets to enable the auto-sort facility to sort the model for this component. Meaningless if
ListModelis not set.- Parameters:
autosort- The allowed values arenull,"false","true", and"ignore.change".Default:
null.- Returns:
- A modified copy of the
thisobject
-
isMultiple
default boolean isMultiple()Returns whether multiple selections are allowed.Default:
false. -
withMultiple
Returns a copy ofthisimmutable component with the specifiedmultiple.Sets whether multiple selections are allowed.
Notice that, if a model is assigned, it will change the model's state (by
Selectable.setMultiple(boolean)).- Parameters:
multiple- True to allow multiple selections.Default:
false.- Returns:
- A modified copy of the
thisobject
-
isCheckmark
default boolean isCheckmark()Returns whether the check mark shall be displayed in front of each item.Default:
false. -
withCheckmark
Returns a copy ofthisimmutable component with the specifiedcheckmark.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.- Parameters:
checkmark- True to enable the check mark in front of each item.Default:
false.- Returns:
- A modified copy of the
thisobject
-
getNonselectableTags
Returns a list of HTML tag names that shall not cause the tree item being selected if they are clicked.Default:
null(it meansbutton,input,textareaandaHTML elements). If you want to select no matter which tag is clicked, please specify an empty string. Specifynullto use the default and""to indicate none. -
withNonselectableTags
Returns a copy ofthisimmutable component with the specifiedname.Sets a list of HTML tag names that shall not cause the tree item being selected if they are clicked.
Default:
null(it meansbutton,input,textareaandaHTML elements). If you want to select no matter which tag is clicked, please specify an empty string.- Parameters:
nonselectableTags- A list of HTML tag names that will not cause the tree item being selected if clicked. Specifynullto use the default and""to indicate none.- Returns:
- A modified copy of the
thisobject
-
isCheckmarkDeselectOther
default boolean isCheckmarkDeselectOther()Returns whether to toggle the selection if clicking on a tree item with a checkmark. Meaningless ifisCheckmark()is falseDefault:
false, if the"org.zkoss.zul.listbox.checkmarkDeselectOthers"library property is not set in zk.xml. -
withCheckmarkDeselectOther
Returns a copy ofthisimmutable component with the specifiedcheckmarkDeselectOther.Sets
trueto prefer to deselect all other items and select the item being clicked. IfisCheckmark()is enabled.Default:
false(not to deselect other items).- Parameters:
checkmarkDeselectOther- True to deselect other items and select the item being clicked.Default:
false- Returns:
- A modified copy of the
thisobject
-
isSelectOnHighlightDisabled
default boolean isSelectOnHighlightDisabled()Returns whether to disable select functionality when highlighting text content with mouse dragging or not.Default:
false, if the"org.zkoss.zul.listbox.selectOnHighlight.disabled"library property is not set in zk.xml. -
withSelectOnHighlightDisabled
Returns a copy ofthisimmutable component with the specifiedselectOnHighlightDisabled.Sets whether to disable select functionality when highlighting text content with mouse dragging or not.
- Parameters:
selectOnHighlightDisabled- True to disable select functionality when highlighting text content with mouse dragging or not.Default:
false- Returns:
- A modified copy of the
thisobject
-
isRightSelect
default boolean isRightSelect()Returns whether to toggle a list item selection on right click, only ifisCheckmark()is enabled.Default:
true, if the"org.zkoss.zul.listbox.rightSelect"library property is not set in zk.xml. -
withRightSelect
Returns a copy ofthisimmutable component with the specifiedrightSelect.Sets whether to enable the selection will be toggled when the user right clicks item, only if
isCheckmark()is enabled.- Parameters:
rightSelect- False not to select/deselect item on right clickDefault:
true- Returns:
- A modified copy of the
thisobject
-
isListgroupSelectable
default boolean isListgroupSelectable()Returns whether Listgroup is selectable.Default:
false -
withListgroupSelectable
Returns a copy ofthisimmutable component with the specifiedlistgroupSelectable.Sets whether to enable or disable the selection will be toggled when the user clicks item on
IListgroupChild.- Parameters:
listgroupSelectable- False not to select/deselect item on clickDefault:
false- Returns:
- A modified copy of the
thisobject
-
getInnerWidth
Returns the inner width of this component. The inner width is the width of the inner table.Default: "100%"
-
withInnerWidth
Returns a copy ofthisimmutable component with the specifiedinnerWidth.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 of this component.Default:
"100%".- Returns:
- A modified copy of the
thisobject
-
getOddRowSclass
Returns the style class for the odd rows.Default:
null -
withOddRowSclass
Returns a copy ofthisimmutable component with the specifiedoddRowSclass.Sets the style class for the odd rows. If the style class doesn't exist, the striping effect disappears. You can provide different effects by providing the proper style classes.
- Parameters:
oddRowSclass- The style class for the odd rowsDefault:
null- Returns:
- A modified copy of the
thisobject
-
getResponsive
Returns the responsive policy set on this component, ornullif unset.Like
Listbox.getResponsive()this is the raw value; the zk.xml fallback is resolved bygetEffectiveResponsive()at render time.Default:
null.- Since:
- 11.0.0
-
withResponsive
Returns a copy ofthisimmutable component with the specifiedresponsive.Sets the responsive policy.
"stacking"turns the items into vertical key-value blocks when the container width falls below the breakpoint;"none"disables it, overriding the library property. The stacking behavior itself is drawn by ZK PE (zkmax).Note:
UiAgent.smartUpdate(Locator, SmartUpdater)is not supported for this property —IListbox.Updaterships the raw attribute while the initial render shipsgetEffectiveResponsive(). Push a whole component withUiAgent.replaceWith(Locator, IComponent)instead.- Parameters:
responsive- one of"stacking","none", ornull(unset).Default:
null.- Returns:
- A modified copy of the
thisobject - Throws:
org.zkoss.zk.ui.WrongValueException- ifresponsiveis neither"stacking","none", nornull.- Since:
- 11.0.0
-
getResponsiveColumns
Returns the responsive columns token string set on this component, used by"stacking"mode, ornullif unset.Like
Listbox.getResponsiveColumns()this is the raw value; the zk.xml fallback is resolved bygetEffectiveResponsiveColumns()at render time. Unset means the client applies its own default cascade"sm-1 md-none".Default:
null.- Since:
- 11.0.0
-
withResponsiveColumns
Returns a copy ofthisimmutable component with the specifiedresponsiveColumns.Sets the responsive columns token string for
"stacking"mode. Bootstrap-style breakpoint tokens separated by whitespace, where each token is<breakpoint>-<value>with breakpoint in {sm, md, lg, xl, xxl} and value either a positive integer (cards per row) ornone(switch back to table mode at and above this breakpoint).The string is stored verbatim — parsing, cascade resolution, and matching against the current container width happen on the client side. Invalid tokens are silently dropped by the client cascade resolver.
Note:
UiAgent.smartUpdate(Locator, SmartUpdater)is not supported for this property —IListbox.Updaterships the raw attribute while the initial render shipsgetEffectiveResponsiveColumns(). Push a whole component withUiAgent.replaceWith(Locator, IComponent)instead.- Parameters:
responsiveColumns- The responsive columns token string, e.g."sm-1 md-2 lg-none".Default:
null.- Returns:
- A modified copy of the
thisobject - Since:
- 11.0.0
-
of
Returns the instance with the givenIListitemBasechildren.- Parameters:
children- The children ofIListitemBase
-
of
Returns the instance with the givenIListitemBasechildren.- Parameters:
children- The children ofIListitemBase
-
ofListhead
Returns the instance with the givenIListheadchild.- Parameters:
listhead- TheIListheadchild
-
ofListheaders
Returns the instance with the givenIListheadercolumn children.a shortcut of
IChildable.withChildren(java.lang.Iterable<? extends I>)- Parameters:
children- TheIListheaderchildren
-
ofListheaders
Returns the instance with the givenIListheadercolumn children.a shortcut of
IChildable.withChildren(java.lang.Iterable<? extends I>)- Parameters:
children- TheIListheaderchildren
-
ofListfoot
Returns the instance with the givenIListfootfoot child.- Parameters:
foot- TheIListfootchild
-
ofId
Returns the instance with the given id.- Parameters:
id- The id to identify this component
-

