|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Combobox
A combo box.
Non-XUL extension. It is used to replace XUL menulist. This class is more
flexible than menulist, such as setAutocomplete(boolean)
setAutodrop(boolean)
.
Default HtmlBasedComponent.getZclass()
: z-combobox.(since 3.5.0)
Events: onOpen, onSelect
Developers can listen to the onOpen event and initializes it when
OpenEvent.isOpen()
is true, and/or clean up if
false.
*
Besides assign a list model, you could assign a renderer (a
ComboitemRenderer
instance) to a combobox, such that the combobox
will use this renderer to render the data returned by
ListModel.getElementAt(int)
. If not assigned, the default renderer, which
assumes a label per combo item, is used. In other words, the default renderer
adds a label to a row by calling toString against the object returned by
ListModel.getElementAt(int)
.
Note: to have better performance, onOpen is sent only if a non-deferrable
event listener is registered (see Deferrable
).
Like Datebox
, the value of a read-only comobobox (InputElement.isReadonly()
) can be changed by dropping down the list and selecting an combo item
(though users cannot type anything in the input box).
Comboitem
Field Summary |
---|
Fields inherited from interface org.zkoss.zk.ui.Component |
---|
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE |
Method Summary | |
---|---|
Comboitem |
appendItemApi(java.lang.String label)
Appends an item. |
void |
close()
Closes the list of combo items ( Comboitem if it was dropped down. |
Comboitem |
getItemAtIndexApi(int index)
Returns the item at the specified index. |
int |
getItemCount()
Returns the number of items. |
ComboitemRenderer |
getItemRenderer()
Returns the renderer to render each row, or null if the default renderer is used. |
java.util.List |
getItems()
Returns a 'live' list of all Comboitem . |
ListModel |
getModel()
Returns the list model associated with this combobox, or null if this combobox is not associated with any list data model. |
int |
getSelectedIndex()
Returns the index of the selected item, or -1 if not selected. |
Comboitem |
getSelectedItemApi()
Returns the selected item. |
boolean |
isAutocomplete()
Returns whether to automatically complete this text box by matching the nearest item ( Comboitem . |
boolean |
isAutodrop()
Returns whether to automatically drop the list if users is changing this text box. |
boolean |
isButtonVisible()
Returns whether the button (on the right of the textbox) is visible. |
void |
open()
Drops down the list of combo items ( Comboitem . |
Comboitem |
removeItemAtApi(int index)
Removes the child item in the list box at the given index. |
void |
setAutocomplete(boolean autocomplete)
Sets whether to automatically complete this text box by matching the nearest item ( Comboitem . |
void |
setAutodrop(boolean autodrop)
Sets whether to automatically drop the list if users is changing this text box. |
void |
setButtonVisible(boolean visible)
Sets whether the button (on the right of the textbox) is visible. |
void |
setItemRenderer(ComboitemRenderer renderer)
Sets the renderer which is used to render each row if getModel()
is not null. |
void |
setItemRenderer(java.lang.String clsnm)
Sets the renderer by use of a class name. |
void |
setModel(ListModel model)
Sets the list model associated with this combobox. |
void |
setOpen(boolean open)
Drops down or closes the list of combo items ( Comboitem . |
void |
setSelectedIndex(int jsel)
Deselects the currently selected items and selects the item with the given index. |
void |
setSelectedItemApi(Comboitem item)
Deselects the currently selected items and selects the given item. |
Methods inherited from interface org.zkoss.zul.api.Textbox |
---|
getRows, getValue, setMultiline, setRows, setType, setValue |
Methods inherited from interface org.zkoss.zul.impl.api.InputElement |
---|
clearErrorMessage, clearErrorMessage, getCols, getErrorMessage, getMaxlength, getName, getRawText, getRawValue, getTabindex, getText, getType, isDisabled, isMultiline, isReadonly, isValid, select, setCols, setConstraint, setDisabled, setMaxlength, setName, setRawValue, setReadonly, setSelectedText, setSelectionRange, setTabindex, setText |
Methods inherited from interface org.zkoss.zul.impl.api.XulElement |
---|
getAction, getContext, getCtrlKeys, getPopup, getTooltip, setAction, setContext, setContext, setCtrlKeys, setPopup, setPopup, setTooltip, setTooltip |
Methods inherited from interface org.zkoss.zk.ui.api.HtmlBasedComponent |
---|
focus, getHeight, getLeft, getSclass, getStyle, getTooltiptext, getTop, getWidth, getZclass, getZindex, getZIndex, setDraggable, setDroppable, setFocus, setHeight, setLeft, setSclass, setStyle, setTooltiptext, setTop, setWidth, setZclass, setZindex, setZIndex |
Methods inherited from interface org.zkoss.zk.ui.ext.Scope |
---|
addScopeListener, getAttribute, hasAttribute, removeAttribute, removeScopeListener, setAttribute |
Methods inherited from interface org.zkoss.zul.ext.Constrainted |
---|
getConstraint, setConstraint |
Method Detail |
---|
ListModel getModel()
Note: for implementation of auto-complete, the result of
getItemCount()
is a subset of model. So, if the model
implemented ListSubModel
interface, you can't use
the index of model to find the comboitem by
getItemAtIndexApi(int)
.
ListSubModel.getSubModel(Object, int)
void setModel(ListModel model)
model
- the list model to associate, or null to dis-associate any
previous model.
UiException
- if failed to initialize with the modelComboitemRenderer getItemRenderer()
void setItemRenderer(ComboitemRenderer renderer)
getModel()
is not null.
Note: changing a render will not cause the combobox 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.
UiException
- if failed to initialize with the modelvoid setItemRenderer(java.lang.String clsnm) throws java.lang.ClassNotFoundException, java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.reflect.InvocationTargetException
java.lang.ClassNotFoundException
java.lang.NoSuchMethodException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.lang.reflect.InvocationTargetException
boolean isAutodrop()
Default: false.
void setAutodrop(boolean autodrop)
boolean isAutocomplete()
Comboitem
.
Default: false.
If true, the nearest item will be searched and the text box is updated automatically. If false, user has to click the item or use the DOWN or UP keys to select it back.
Note: this feature is reserved and not yet implemented. Don't confuse it with the auto-completion feature mentioned by other framework. Such kind of auto-completion is supported well by listening to the onChanging event.
void setAutocomplete(boolean autocomplete)
Comboitem
.
void setOpen(boolean open)
Comboitem
.
open()
,
close()
void open()
Comboitem
. It is the same as
setOpen(true).
void close()
Comboitem
if it was dropped down.
It is the same as setOpen(false).
boolean isButtonVisible()
Default: true.
void setButtonVisible(boolean visible)
java.util.List getItems()
Comboitem
. By live we mean you can
add or remove them directly with the List interface.
Currently, it is the same as Component.getChildren()
. However, we might add
other kind of children in the future.
int getItemCount()
Comboitem getItemAtIndexApi(int index)
Comboitem appendItemApi(java.lang.String label)
Comboitem removeItemAtApi(int index)
Comboitem getSelectedItemApi()
void setSelectedItemApi(Comboitem item)
Note: if the label of comboitem has the same more than one, the first
comboitem will be selected at client side, it is a limitation of
Combobox
and it is different from Listbox
.
void setSelectedIndex(int jsel)
Note: if the label of comboitem has the same more than one, the first
comboitem will be selected at client side, it is a limitation of
Combobox
and it is different from Listbox
.
int getSelectedIndex()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |