E - Element type in modelpublic class Searchbox<E>
extends org.zkoss.zk.ui.HtmlBasedComponent
implements org.zkoss.zk.ui.ext.Disable
Available in ZK EE.
Default getZclass(): z-searchbox.
Events: onOpen, onSelect, onSearching, onAfterRender
Besides assign a list model, you could assign a renderer
(a ItemRenderer instance) to a searchbox, such that
the searchbox will use this renderer to render the data returned by
ListModel.getElementAt(int).
If not assigned, the default renderer, which assumes a label per item, is used.
| Constructor and Description |
|---|
Searchbox() |
| Modifier and Type | Method and Description |
|---|---|
void |
clearSelection()
Clears the selection.
|
Object |
clone() |
org.zkoss.util.Converter<Collection<E>,String> |
getItemConverter()
Returns the converter that generates the label text shown in the searchbox
from selected items, or null to use the default implementation.
|
org.zkoss.zul.ItemRenderer<E> |
getItemRenderer()
Returns the renderer to render each item, or null if the default
renderer is used.
|
org.zkoss.zul.ListModel<E> |
getModel()
Returns the model associated with this searchbox, or null if this searchbox
is not associated with any list data model.
|
String |
getPlaceholder()
Returns the placeholder text.
|
String |
getSearchMessage()
Returns the placeholder message of the search text field,
or null to use the default message.
|
int |
getSelectedCount()
Returns the number of items being selected.
|
E |
getSelectedItem()
Returns the selected item, or null if no item is selected.
|
Set<E> |
getSelectedItems()
Returns all selected items.
|
String |
getZclass() |
void |
invalidate() |
boolean |
isAutoclose()
Returns whether to automatically close the list if a user is selected
any item.
|
protected boolean |
isChildable() |
boolean |
isDisabled() |
boolean |
isMultiple()
Returns whether multiple selections are allowed.
|
boolean |
isOpen()
Returns whether this searchbox is open.
|
void |
onInitRender()
Handles a private event, onInitRender.
|
void |
onPageAttached(org.zkoss.zk.ui.Page newpage,
org.zkoss.zk.ui.Page oldpage) |
void |
onPageDetached(org.zkoss.zk.ui.Page page) |
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 |
setAutoclose(boolean autoclose)
Sets whether to automatically close the list if a user is selected
any item.
|
void |
setDisabled(boolean disabled) |
void |
setItemConverter(org.zkoss.util.Converter<Collection<E>,String> converter)
Sets the converter that generates the label text shown in the searchbox
from selected items.
|
void |
setItemConverter(String clsnm)
Sets the converter by use of a class name.
|
void |
setItemRenderer(org.zkoss.zul.ItemRenderer<E> 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<E> model)
Sets the list model associated with this searchbox.
|
void |
setMultiple(boolean multiple)
Sets whether multiple selections are allowed.
|
void |
setOpen(boolean open)
Drops down or closes the list of items.
|
void |
setPlaceholder(String placeholder)
Sets the placeholder text that is displayed when the selected item is empty.
|
void |
setSearchMessage(String searchMessage)
Sets the placeholder message of the search text field.
|
void |
setSelectedItem(E item)
Deselects all of the currently selected items and selects the given item.
|
void |
setSelectedItems(Collection<E> selectedItems)
Selects the given items.
|
addSclass, evalCSSFlex, focus, getAction, getDraggable, getDroppable, getExtraCtrl, 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 org.zkoss.zul.ListModel<E> getModel()
public void setModel(org.zkoss.zul.ListModel<E> model)
model - the list model to associate, or null to dis-associate any
previous model. If not null, it must implement Selectable.org.zkoss.zk.ui.UiException - if failed to initialize with the modelpublic void onInitRender()
public org.zkoss.zul.ItemRenderer<E> getItemRenderer()
public void setItemRenderer(org.zkoss.zul.ItemRenderer<E> renderer)
getModel() is not null.
Note: changing a render will cause the searchbox to re-render.
renderer - the renderer, or null to use the default.public void setItemRenderer(String clsnm) throws ReflectiveOperationException
clsnm - The class nameReflectiveOperationException - if failed to initialize the rendererpublic org.zkoss.util.Converter<Collection<E>,String> getItemConverter()
public void setItemConverter(org.zkoss.util.Converter<Collection<E>,String> converter)
converter - the converter, or null to use the default implementation.public void setItemConverter(String clsnm) throws ReflectiveOperationException
clsnm - The class nameReflectiveOperationException - if failed to initialize the converterpublic String getSearchMessage()
public void setSearchMessage(String searchMessage)
public String getPlaceholder()
public void setPlaceholder(String placeholder)
public boolean isMultiple()
Default: false.
public void setMultiple(boolean multiple)
Notice that, if a model is assigned, it will change the model's
state (by Selectable.setMultiple(boolean)).
public boolean isOpen()
Default: false.
public void setOpen(boolean open)
public boolean isDisabled()
isDisabled in interface org.zkoss.zk.ui.ext.Disablepublic void setDisabled(boolean disabled)
setDisabled in interface org.zkoss.zk.ui.ext.Disablepublic boolean isAutoclose()
Default: false
public void setAutoclose(boolean autoclose)
public void setSelectedItems(Collection<E> selectedItems)
public E getSelectedItem()
public void setSelectedItem(E item)
public int getSelectedCount()
public void clearSelection()
protected 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 String getZclass()
getZclass in class org.zkoss.zk.ui.HtmlBasedComponentprotected boolean isChildable()
isChildable in class org.zkoss.zk.ui.AbstractComponentpublic 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.AbstractComponentpublic 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.AbstractComponentCopyright © 2026. All rights reserved.