public class Chosenbox
extends org.zkoss.zk.ui.HtmlBasedComponent
Default getZclass(): z-chosenbox.
It does not create child widgets for each data, so the memory usage is much
lower at the server.
| Modifier and Type | Class and Description |
|---|---|
protected class |
Chosenbox.ExtraCtrl
A utility class to implement
HtmlBasedComponent.getExtraCtrl(). |
| Constructor and Description |
|---|
Chosenbox() |
| Modifier and Type | Method and Description |
|---|---|
void |
addItemToSelection(Object o)
Add an item into selection.
|
void |
clearSelection()
Clear all selected objects.
|
Object |
clone() |
String |
getCreateMessage()
Returns the create message of this component.
|
String |
getEmptyMessage()
Returns the emptyMessage of the input of this component.
|
Object |
getExtraCtrl() |
<T> org.zkoss.zul.ItemRenderer<T> |
getItemRenderer()
Returns the renderer to render each item, or null if the default renderer
is used.
|
<T> org.zkoss.zul.ListModel<T> |
getModel()
Returns the model associated with this chosenbox, or null if this
chosenbox is not associated with any list data model.
|
String |
getName()
Returns the name of this component.
|
String |
getNoResultsText()
Returns the no-result text of this component.
|
<T> org.zkoss.zul.ItemRenderer<T> |
getRealRenderer() |
int |
getSelectedIndex()
Returns the index of the selected item (-1 if no one is selected).
|
<T> Set<T> |
getSelectedObjects()
Returns the selected objects.
|
String |
getSeparator()
Returns the separate chars of this component.
|
String |
getZclass() |
void |
invalidate() |
protected boolean |
isChildable() |
boolean |
isCreatable()
Returns whether can create new item.
|
boolean |
isDisabled()
Returns whether it is disabled.
|
boolean |
isInplace()
Return whether to display Chosenbox's selection as a comma separate label,
under inplace="true", when user clicks the label, it turns into a chosenbox.
|
boolean |
isOpen() |
void |
onInitRender() |
void |
onInitSelection() |
void |
onPageAttached(org.zkoss.zk.ui.Page newpage,
org.zkoss.zk.ui.Page oldpage) |
void |
onPageDetached(org.zkoss.zk.ui.Page page) |
void |
removeItemFromSelection(Object o)
Remove an item from selection.
|
protected void |
renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) |
void |
service(org.zkoss.zk.au.AuRequest request,
boolean everError) |
void |
sessionDidActivate(org.zkoss.zk.ui.Page page) |
void |
sessionWillPassivate(org.zkoss.zk.ui.Page page) |
void |
setCreatable(boolean creatable)
Sets whether can create new item.
|
void |
setCreateMessage(String createMessage)
Sets the create message of this component.
|
void |
setDisabled(boolean disabled)
Sets whether it is disabled.
|
void |
setEmptyMessage(String emptyMessage)
Sets the emptyMessage of the input of this component.
|
void |
setInplace(boolean inplace)
Set whether to display Chosenbox's selection as a comma separate label,
under inplace="true", when user clicks the label, it turns into a chosenbox.
|
void |
setItemRenderer(org.zkoss.zul.ItemRenderer<?> renderer)
Sets the renderer which is used to render each item if
getModel()
is not null. |
void |
setItemRenderer(String clsnm)
Sets the renderer by use of a class name.
|
void |
setModel(org.zkoss.zul.ListModel<?> model)
Sets the list model associated with this chosenbox.
|
void |
setName(String name)
Sets the name of the input element of this component.
|
void |
setNoResultsText(String noResultsText)
Sets the no-result text of this component.
|
void |
setOpen(boolean open) |
void |
setSelectedIndex(int jsel)
Sets the index of the selected item (-1 if no one is selected).
|
void |
setSelectedObjects(Collection<?> objects)
Sets the selected objects.
|
void |
setSeparator(String separator)
Sets the separate chars of this component.
|
addSclass, evalCSSFlex, focus, getAction, getDraggable, getDroppable, getHeight, getHflex, getLeft, getPropertyAccess, getRenderdefer, getSclass, getStyle, getTabindex, getTabindexInteger, getTooltiptext, getTop, getVflex, getWidth, getZindex, getZIndex, removeSclass, removeSclass, setAction, setClass, setDraggable, setDroppable, setFocus, setHeight, setHeight0, setHeightDirectly, setHflex, setHflex0, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, setStyle, setTabindex, setTabindex, setTooltiptext, setTop, setTopDirectly, setVflex, setVflex0, setVflexDirectly, setWidth, setWidth0, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectlyaddAnnotation, addAnnotation, addCallback, addClientEvent, addEventHandler, addEventListener, addEventListener, addForward, addForward, addForward, addForward, addMoved, addRedrawCallback, addScopeListener, addShadowRoot, addShadowRootBefore, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildAdded, beforeChildRemoved, beforeParentChanged, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableBindingAnnotation, disableClientUpdate, enableBindingAnnotation, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotation, getAnnotations, 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, getId, getLastChild, getListenerIterator, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getRedrawCallback, getRoot, getShadowFellowIfAny, getShadowRoots, getShadowVariable, getShadowVariable, getShadowVariable0, getSpaceOwner, getSpecialRendererOutput, getStubonly, getSubBindingAnnotationCount, getTemplate, getTemplateNames, getUuid, getWidgetAttribute, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasBindingAnnotation, hasFellow, hasFellow, hasSubBindingAnnotation, insertBefore, invalidatePartial, isInitialized, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onChildRemoved, onWrongValue, query, queryAll, redraw, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeCallback, removeChild, removeEventListener, removeForward, removeForward, removeRedrawCallback, removeScopeListener, removeShadowRoot, render, render, render, replace, response, response, response, service, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setClientAttribute, setClientDataAttribute, setDefinition, setDefinition, setId, setMold, setPage, setPageBefore, setParent, setStubonly, setStubonly, setSubBindingAnnotationCount, setTemplate, setVisible, setVisibleDirectly, setWidgetAttribute, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateByClient, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerializepublic String getZclass()
getZclass in class org.zkoss.zk.ui.HtmlBasedComponentpublic void setOpen(boolean open)
public boolean isOpen()
public boolean isDisabled()
Default: false.
public void setDisabled(boolean disabled)
public String getName()
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.
public void setName(String name)
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.
name - the name of this component.public String getEmptyMessage()
Default: null.
The emptyMessage will be displayed in input if nothing selected and not focused.
public void setEmptyMessage(String emptyMessage)
The emptyMessage will be displayed in input if nothing selected and not focused.
emptyMessage - the emptyMessage of the input of this component.public String getNoResultsText()
Default: null.
The no-result text will be displayed in popup if nothing match to the input value and can not create either, the syntax "{0}" will be replaced with the input value at client side.
public void setNoResultsText(String noResultsText)
The no-result text will be displayed in popup if nothing match to the input value and can not create either, the syntax "{0}" will be replaced with the input value at client side.
noResultsText - the no-result text of this component.public String getCreateMessage()
Default: null.
The create message will be displayed in popup if nothing match to the input value but can create as new label, the syntax "{0}" will be replaced with the input value at client side.
public void setCreateMessage(String createMessage)
The create message will be displayed in popup if nothing match to the input value but can create as new label, the syntax "{0}" will be replaced with the input value at client side.
createMessage - the create message of this component.public String getSeparator()
Support: 0-9, A-Z (case insensitive), and ,.;'[]/\-=
Default: null.
The separate chars will work as 'Enter' key, it will not considered as input value but send onSerch or onSearching while key up.
public void setSeparator(String separator)
Support: 0-9, A-Z (case insensitive), and ,.;'[]/\-=
The separate chars will work as 'Enter' key, it will not considered as input value but send onSerch or onSelect while key up.
public <T> Set<T> getSelectedObjects()
public void setSelectedObjects(Collection<?> objects)
objects - the objects to select.public int getSelectedIndex()
public void setSelectedIndex(int jsel)
jsel - the index to select.public boolean isCreatable()
Default: false.
true: will show create message while value of input not exists.
false: will show no result message while value of input not exists.
public void setCreatable(boolean creatable)
Default: false.
true: will show create message while value of input not exists.
false: will show no-result text while value of input not exists.
creatable - the boolean value.public boolean isInplace()
public void setInplace(boolean inplace)
inplace - to display Chosenbox's selection as a comma separate labelpublic <T> org.zkoss.zul.ItemRenderer<T> getRealRenderer()
public <T> org.zkoss.zul.ItemRenderer<T> getItemRenderer()
public <T> org.zkoss.zul.ListModel<T> getModel()
public void setModel(org.zkoss.zul.ListModel<?> model)
model - the list model to associate, or null to dis-associate any
previous model.org.zkoss.zk.ui.UiException - if failed to initialize with the modelpublic void clearSelection()
public void addItemToSelection(Object o)
o - the object to add.public void removeItemFromSelection(Object o)
o - the object to remove.protected boolean isChildable()
isChildable in class org.zkoss.zk.ui.AbstractComponentpublic void setItemRenderer(org.zkoss.zul.ItemRenderer<?> renderer)
getModel()
is not null.
Note: changing a render will not cause the chosenbox to re-render. If you
want it to re-render, you could assign the same model again (i.e.,
setModel(getModel())), or fire an ListDataEvent event.
renderer - the renderer, or null to use the default.org.zkoss.zk.ui.UiException - if failed to initialize with the modelpublic void setItemRenderer(String clsnm) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InstantiationException, InvocationTargetException
public void onInitRender()
public void onInitSelection()
public void invalidate()
invalidate in interface org.zkoss.zk.ui.Componentinvalidate in class org.zkoss.zk.ui.AbstractComponentpublic Object clone()
clone in interface org.zkoss.zk.ui.Componentclone in class org.zkoss.zk.ui.HtmlBasedComponentpublic void sessionWillPassivate(org.zkoss.zk.ui.Page page)
sessionWillPassivate in interface org.zkoss.zk.ui.sys.ComponentCtrlsessionWillPassivate in class org.zkoss.zk.ui.AbstractComponentpublic void sessionDidActivate(org.zkoss.zk.ui.Page page)
sessionDidActivate in interface org.zkoss.zk.ui.sys.ComponentCtrlsessionDidActivate in class org.zkoss.zk.ui.AbstractComponentprotected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer)
throws IOException
renderProperties in class org.zkoss.zk.ui.HtmlBasedComponentIOExceptionpublic void service(org.zkoss.zk.au.AuRequest request,
boolean everError)
service in interface org.zkoss.zk.ui.sys.ComponentCtrlservice in class org.zkoss.zk.ui.HtmlBasedComponentpublic Object getExtraCtrl()
getExtraCtrl in interface org.zkoss.zk.ui.sys.ComponentCtrlgetExtraCtrl in class org.zkoss.zk.ui.HtmlBasedComponentpublic void onPageAttached(org.zkoss.zk.ui.Page newpage,
org.zkoss.zk.ui.Page oldpage)
onPageAttached in interface org.zkoss.zk.ui.sys.ComponentCtrlonPageAttached in class org.zkoss.zk.ui.AbstractComponentpublic void onPageDetached(org.zkoss.zk.ui.Page page)
onPageDetached in interface org.zkoss.zk.ui.sys.ComponentCtrlonPageDetached in class org.zkoss.zk.ui.AbstractComponentCopyright © 2026. All rights reserved.