Class Chosenbox
- All Implemented Interfaces:
Serializable,Cloneable,Component,Scope,ComponentCtrl
Default getZclass(): z-chosenbox.
It does not create child widgets for each data, so the memory usage is much
lower at the server.
- Since:
- 6.0.1
- Author:
- benbai
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classA utility class to implementHtmlBasedComponent.getExtraCtrl().Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent
AbstractComponent.Children, AbstractComponent.ForwardInfo, AbstractComponent.TargetInfo -
Field Summary
FieldsFields inherited from class org.zkoss.zk.ui.HtmlBasedComponent
_zclassFields inherited from interface org.zkoss.zk.ui.Component
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPEFields inherited from interface org.zkoss.zk.ui.sys.ComponentCtrl
AFTER_CHILD_ADDED, AFTER_CHILD_REMOVED, AFTER_CLONED, AFTER_PAGE_ATTACHED, AFTER_PAGE_DETACHED, AFTER_PARENT_CHANGED, CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd an item into selection.voidClear all selected objects.clone()Clones the component.Returns the create message of this component.Returns the emptyMessage of the input of this component.Returns the client control for this component.Returns the additional attributes which is set bysetInputAttributes(Map<String, String> inputAttributes).<T> ItemRenderer<T>Returns the renderer to render each item, or null if the default renderer is used.<T> ListModel<T>getModel()Returns the model associated with this chosenbox, or null if this chosenbox is not associated with any list data model.getName()Returns the name of this component.Returns the no-result text of this component.<T> ItemRenderer<T>intReturns the index of the selected item (-1 if no one is selected).<T> Set<T>Returns the selected objects.Returns the separate chars of this component.Returns the ZK Cascading Style class for this component.voidInvalidates this component by setting the dirty flag such that it will be redraw the whole content of this component and its dependencies later.protected booleanReturns whether this component can have a child.booleanReturns whether creates new item.booleanReturns whether it is disabled.booleanReturn whether to display Chosenbox's selection as a comma separate label, under inplace="true", when user clicks the label, it turns into a chosenbox.booleanisOpen()voidvoidvoidonPageAttached(Page newpage, Page oldpage) Default: handles special event listeners.voidonPageDetached(Page page) Default: handles special event listeners.voidRemove an item from selection.protected voidrenderProperties(ContentRenderer renderer) Renders the content of this component, excluding the enclosing tags and children.voidProcesses an AU request.voidsessionDidActivate(Page page) Notification that the session, which owns this component, has just been activated (a.k.a., deserialized).voidsessionWillPassivate(Page page) Notification that the session, which owns this component, is about to be passivated (a.k.a., serialized).voidsetCreatable(boolean creatable) Sets whether can create new item.voidsetCreateMessage(String createMessage) Sets the create message of this component.voidsetDisabled(boolean disabled) Sets whether it is disabled.voidsetEmptyMessage(String emptyMessage) Sets the emptyMessage of the input of this component.voidsetInplace(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.voidsetInputAttributes(String inputAttributes) Sets some additional attributes to the filter input html tag in the component.voidsetInputAttributes(Map<String, String> inputAttributes) Sets some additional attributes to the filter input html tag in the component.voidsetItemRenderer(String clsnm) Sets the renderer by use of a class name.voidsetItemRenderer(ItemRenderer<?> renderer) Sets the renderer which is used to render each item ifgetModel()is not null.voidSets the list model associated with this chosenbox.voidSets the name of the input element of this component.voidsetNoResultsText(String noResultsText) Sets the no-result text of this component.voidsetOpen(boolean open) voidsetSelectedIndex(int jsel) Sets the index of the selected item (-1 if no one is selected).voidsetSelectedObjects(Collection<?> objects) Sets the selected objects.voidsetSeparator(String separator) Sets the separate chars of this component.Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
addSclass, evalCSSFlex, focus, getAction, getClientAction, getDraggable, getDroppable, getHeight, getHflex, getLeft, getPropertyAccess, getRenderdefer, getSclass, getSkeleton, getStyle, getTabindex, getTabindexInteger, getTooltiptext, getTop, getVflex, getWidth, getZindex, getZIndex, removeSclass, removeSclass, setAction, setClass, setClientAction, setDraggable, setDroppable, setFocus, setHeight, setHeight0, setHeightDirectly, setHflex, setHflex0, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, setSkeleton, setStyle, setTabindex, setTabindex, setTooltiptext, setTop, setTopDirectly, setVflex, setVflex0, setVflexDirectly, setWidth, setWidth0, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectlyMethods 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, beforeChildAdded, 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, getStubonlyDescendants, getSubBindingAnnotationCount, getTemplate, getTemplateNames, getUuid, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasBindingAnnotation, hasFellow, hasFellow, hasSubBindingAnnotation, initIndexCacheMap, insertBefore, isDisabledHostChanged, isInitialized, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onChildRemoved, onParentChanged, onWrongValue, query, queryAll, redraw, redrawChildren, 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, setMold, setPage, setPageBefore, setParent, setStubonly, setStubonly, setStubonlyDescendants, setSubBindingAnnotationCount, setTemplate, setVisible, setVisibleDirectly, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateByClient, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerialize
-
Field Details
-
ATTR_FILTER_LOGIC
- See Also:
-
ATTR_FILTER_LOGIC_CONTAINS
- See Also:
-
ATTR_FILTER_LOGIC_STARTS_WITH
- See Also:
-
-
Constructor Details
-
Chosenbox
public Chosenbox()
-
-
Method Details
-
getZclass
Description copied from class:HtmlBasedComponentReturns the ZK Cascading Style class for this component. It usually depends on the implementation of the mold (AbstractComponent.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 ofHtmlBasedComponent.getZclass(). Once it is changed, the default style won't be applied at all. If you want to perform small adjustments, useHtmlBasedComponent.setSclass(java.lang.String)instead.- Overrides:
getZclassin classHtmlBasedComponent- See Also:
-
setOpen
public void setOpen(boolean open) -
isOpen
public boolean isOpen() -
isDisabled
public boolean isDisabled()Returns whether it is disabled.Default: false.
-
setDisabled
public void setDisabled(boolean disabled) Sets whether it is disabled. -
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
Sets the name of the input element 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.
-
getEmptyMessage
Returns the emptyMessage of the input of this component.Default: null.
The emptyMessage will be displayed in input if nothing selected and not focused.
-
setEmptyMessage
Sets the emptyMessage of the input of this component.The emptyMessage will be displayed in input if nothing selected and not focused.
- Parameters:
emptyMessage- the emptyMessage of the input of this component.
-
getInputAttributes
Returns the additional attributes which is set bysetInputAttributes(Map<String, String> inputAttributes).The attributes are rendered on the filter input html tag of this component.
- Returns:
- inputAttributes a Map with attribute names as the keys, or null if not set.
- Since:
- 11.0.0
-
setInputAttributes
Sets some additional attributes to the filter input html tag in the component. This will only reset the additional attributes that are set by this method.It is also how to specify the HTML
autocompleteattribute required by WCAG 1.3.5 (Identify Input Purpose) when this component collects information about the user, for exampleautocomplete=country-name.- Parameters:
inputAttributes- a Map with attribute names as the keys.- Since:
- 11.0.0
-
setInputAttributes
Sets some additional attributes to the filter input html tag in the component. This will only reset the additional attributes that are set by this method.- Parameters:
inputAttributes- a String of attributes separated by ";" and follow name=value rule. for example: "autocomplete=country-name"- Since:
- 11.0.0
-
getNoResultsText
Returns the no-result text of this component.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.
-
setNoResultsText
Sets the no-result text of this component.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.
- Parameters:
noResultsText- the no-result text of this component.
-
getCreateMessage
Returns the create message of this component.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.
-
setCreateMessage
Sets the create message of this component.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.
- Parameters:
createMessage- the create message of this component.
-
getSeparator
Returns the separate chars of this component.Support: 0-9, A-Z (case-insensitive), and ,.;'[]/\-=
Default: null.
The separate chars will work as 'Enter' key, it will be not considered as input value but send onSerch or onSearching while key up.
-
setSeparator
Sets the separate chars of this component.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.
-
getSelectedObjects
Returns the selected objects. -
setSelectedObjects
Sets the selected objects.- Parameters:
objects- the objects to select.
-
getSelectedIndex
public int getSelectedIndex()Returns the index of the selected item (-1 if no one is selected). -
setSelectedIndex
public void setSelectedIndex(int jsel) Sets the index of the selected item (-1 if no one is selected). If model already exists, it will update the selection of model.- Parameters:
jsel- the index to select.
-
isCreatable
public boolean isCreatable()Returns whether creates new item.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.
-
setCreatable
public void setCreatable(boolean creatable) Sets whether can create new item.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.
- Parameters:
creatable- the boolean value.
-
isInplace
public 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.- Returns:
- whether to display Chosenbox's selection as a comma separate label
- Since:
- 8.5.2
-
setInplace
public 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.- Parameters:
inplace- to display Chosenbox's selection as a comma separate label- Since:
- 8.5.2
-
getRealRenderer
-
getItemRenderer
Returns the renderer to render each item, or null if the default renderer is used. -
getModel
Returns the model associated with this chosenbox, or null if this chosenbox is not associated with any list data model. -
setModel
Sets the list model associated with this chosenbox. If a non-null model is assigned, no matter whether it is the same as the previous, it will always cause re-render.- Parameters:
model- the list model to associate, or null to dis-associate any previous model.- Throws:
UiException- if failed to initialize with the model
-
clearSelection
public void clearSelection()Clear all selected objects. -
addItemToSelection
Add an item into selection.- Parameters:
o- the object to add.
-
removeItemFromSelection
Remove an item from selection.- Parameters:
o- the object to remove.
-
isChildable
protected boolean isChildable()Description copied from class:AbstractComponentReturns whether this component can have a child.Default: return true (means it can have children).
- Overrides:
isChildablein classAbstractComponent
-
setItemRenderer
Sets the renderer which is used to render each item ifgetModel()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
ListDataEventevent.- Parameters:
renderer- the renderer, or null to use the default.- Throws:
UiException- if failed to initialize with the model
-
setItemRenderer
public void setItemRenderer(String clsnm) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InstantiationException, InvocationTargetException Sets the renderer by use of a class name. It creates an instance automatically. -
onInitRender
public void onInitRender() -
onInitSelection
public void onInitSelection() -
invalidate
public void invalidate()Description copied from interface:ComponentInvalidates this component by setting the dirty flag such that it will be redraw the whole content of this component and its dependencies later. And, the widget associated with this component and all its descendant at the client will be deleted and recreated, too.If the application is totally controlled by the server side (i.e., you don't write client codes), you rarely need to access this method.
It can be called only in the request-processing and event-processing phases. However, it is NOT allowed in the rendering phase.
- Specified by:
invalidatein interfaceComponent- Overrides:
invalidatein classAbstractComponent
-
clone
Description copied from interface:ComponentClones the component. All of its children and descendants are cloned. Also, ID are preserved.- Specified by:
clonein interfaceComponent- Overrides:
clonein classHtmlBasedComponent- Returns:
- the new component. Notice that it doesn't belong to any page, nor desktop. It doesn't have a parent, either.
-
sessionWillPassivate
Description copied from interface:ComponentCtrlNotification that the session, which owns this component, is about to be passivated (a.k.a., serialized).Note: only root components are notified by this method.
- Specified by:
sessionWillPassivatein interfaceComponentCtrl- Overrides:
sessionWillPassivatein classAbstractComponent
-
sessionDidActivate
Description copied from interface:ComponentCtrlNotification that the session, which owns this component, has just been activated (a.k.a., deserialized).Note: only root components are notified by this method.
- Specified by:
sessionDidActivatein interfaceComponentCtrl- Overrides:
sessionDidActivatein classAbstractComponent
-
renderProperties
Description copied from class:HtmlBasedComponentRenders the content of this component, excluding the enclosing tags and children.- Overrides:
renderPropertiesin classHtmlBasedComponent- Throws:
IOException
-
service
Description copied from class:HtmlBasedComponentProcesses an AU request.Default: it handles onClick, onDoubleClick, onRightClick onMove, onSize, onZIndex.
- Specified by:
servicein interfaceComponentCtrl- Overrides:
servicein classHtmlBasedComponenteverError- whether any error ever occurred before processing this request.- See Also:
-
getExtraCtrl
Description copied from class:HtmlBasedComponentReturns the client control for this component. It is used only by component developers.Default: creates an instance of
HtmlBasedComponent.ExtraCtrl.- Specified by:
getExtraCtrlin interfaceComponentCtrl- Overrides:
getExtraCtrlin classHtmlBasedComponent- Returns:
- null if no special handling required. If the component
requires some special controls, it could return an object that
implements one or several interfaces in the org.zkoss.zk.ui.ext.render
package.
For example,
Cropper. - See Also:
-
onPageAttached
Description copied from class:AbstractComponentDefault: handles special event listeners.- Specified by:
onPageAttachedin interfaceComponentCtrl- Overrides:
onPageAttachedin classAbstractComponent- Parameters:
newpage- the new page (never null).oldpage- the previous page, if any, or null if it didn't belong to any page.- See Also:
-
onPageDetached
Description copied from class:AbstractComponentDefault: handles special event listeners.- Specified by:
onPageDetachedin interfaceComponentCtrl- Overrides:
onPageDetachedin classAbstractComponent- Parameters:
page- the previous page (never null)- See Also:
-