|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.zkoss.zk.ui.AbstractComponent
org.zkoss.zk.ui.HtmlBasedComponent
org.zkoss.zul.impl.XulElement
org.zkoss.zul.Listbox
public class Listbox
A listbox.
Event:
See Specification.
Besides creating Listitem programmingly, you could assign
a data model (a ListModel instance) to a listbox
via setModel(org.zkoss.zul.ListModel) and then
the listbox will retrieve data via ListModel.getElementAt(int) when
necessary.
Besides assign a list model, you could assign a renderer
(a ListitemRenderer instance) to a listbox, such that
the listbox will use this
renderer to render the data returned by ListModel.getElementAt(int).
If not assigned, the default renderer, which assumes a label per
list 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)
There are two ways to handle long content: scrolling and paging.
If AbstractComponent.getMold() is "default", scrolling is used if setHeight(java.lang.String)
is called and too much content to display.
If AbstractComponent.getMold() is "paging", paging is used if two or more pages are
required. To control the number of items to display in a page, use
setPageSize(int).
If paging is used, the page controller is either created automatically
or assigned explicity by setPaginal(org.zkoss.zul.ext.Paginal).
The paging controller specified explicitly by setPaginal(org.zkoss.zul.ext.Paginal) is called
the external page controller. It is useful if you want to put the paging
controller at different location (other than as a child component), or
you want to use the same controller to control multiple listboxes.
Default HtmlBasedComponent.getSclass(): listbox.
ListModel,
ListitemRenderer,
ListitemRendererExt,
Serialized Form| Nested Class Summary | |
|---|---|
protected class |
Listbox.ExtraCtrl
A utility class to implement AbstractComponent.getExtraCtrl(). |
| Field Summary |
|---|
| Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent |
|---|
RS_NO_DISPLAY, RS_NO_HEIGHT, RS_NO_WIDTH |
| Fields inherited from interface org.zkoss.zk.ui.Component |
|---|
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE |
| Constructor Summary | |
|---|---|
Listbox()
|
|
| Method Summary | |
|---|---|
void |
addItemToSelection(Listitem item)
Selects the given item, without deselecting any other items that are already selected.. |
Listitem |
appendItem(java.lang.String label,
java.lang.String value)
Appends an item. |
void |
clearSelection()
Clears the selection. |
java.lang.Object |
clone()
|
int |
getIndexOfItem(Listitem item)
Returns the index of the specified item, or -1 if not found. |
Listitem |
getItemAtIndex(int index)
Returns the item at the specified index. |
int |
getItemCount()
Returns the number of items. |
ListitemRenderer |
getItemRenderer()
Returns the renderer to render each item, or null if the default renderer is used. |
java.util.List |
getItems()
Returns a live list of all Listitem. |
Listfoot |
getListfoot()
Returns Listfoot belonging to this listbox, or null
if no list footers at all. |
Listhead |
getListhead()
Returns Listhead belonging to this listbox, or null
if no list headers at all. |
int |
getMaxlength()
Returns the maximal length of each item's label. |
ListModel |
getModel()
Returns the list model associated with this listbox, or null if this listbox is not associated with any list data model. |
java.lang.String |
getName()
Returns the name of this component. |
java.lang.String |
getOuterAttrs()
|
int |
getPageSize()
Returns the page size, aka., the number items per page. |
Paginal |
getPaginal()
Returns the paging controller, or null if not available. |
Paging |
getPaging()
Returns the child paging controller that is created automatically, or null if mold is not "paging", or the controller is specified externally by setPaginal(org.zkoss.zul.ext.Paginal). |
int |
getPreloadSize()
Returns the number of items to preload when receiving the rendering request from the client. |
int |
getRows()
Returns the rows. |
int |
getSelectedCount()
Returns the number of items being selected. |
int |
getSelectedIndex()
Returns the index of the selected item (-1 if no one is selected). |
Listitem |
getSelectedItem()
Returns the selected item. |
java.util.Set |
getSelectedItems()
Returns all selected items. |
java.lang.String |
getSeltype()
Returns the seltype. |
int |
getTabindex()
Returns the tab order of this component. |
int |
getVisibleBegin()
Returns the index of the first visible child. |
int |
getVisibleEnd()
Returns the index of the last visible child. |
boolean |
insertBefore(org.zkoss.zk.ui.Component newChild,
org.zkoss.zk.ui.Component refChild)
|
boolean |
isCheckmark()
Returns whether the check mark shall be displayed in front of each item. |
boolean |
isDisabled()
Returns whether it is disabled. |
boolean |
isMultiple()
Returns whether multiple selections are allowed. |
boolean |
isVflex()
Returns whether to grow and shrink vertical to fit their given space, so called vertial flexibility. |
protected java.lang.Object |
newExtraCtrl()
|
void |
onChildAdded(org.zkoss.zk.ui.Component child)
|
void |
onChildRemoved(org.zkoss.zk.ui.Component child)
|
void |
onInitRender()
Handles a private event, onInitRender. |
void |
onPaging()
Called when the onPaging event is received (from getPaginal()). |
boolean |
removeChild(org.zkoss.zk.ui.Component child)
|
Listitem |
removeItemAt(int index)
Removes the child item in the list box at the given index. |
void |
removeItemFromSelection(Listitem item)
Deselects the given item without deselecting other items. |
void |
renderAll()
Renders all Listitem if not loaded yet,
with getItemRenderer(). |
Listitem |
renderItem(Listitem li)
Renders the specified Listitem if not loaded yet,
with getItemRenderer(). |
void |
renderItems(java.util.Set items)
|
void |
selectAll()
Selects all items. |
void |
selectItem(Listitem item)
Deselects all of the currently selected items and selects the given item. |
void |
setCheckmark(boolean checkmark)
Sets whether the check mark shall be displayed in front of each item. |
void |
setDisabled(boolean disabled)
Sets whether it is disabled. |
void |
setHeight(java.lang.String height)
|
void |
setItemRenderer(ListitemRenderer renderer)
Sets the renderer which is used to render each item if getModel() is not null. |
void |
setItemRenderer(java.lang.String clsnm)
Sets the renderer by use of a class name. |
void |
setMaxlength(int maxlength)
Sets the maximal length of each item's label. |
void |
setModel(ListModel model)
Sets the list model associated with this listbox. |
void |
setMold(java.lang.String mold)
|
void |
setMultiple(boolean multiple)
Sets whether multiple selections are allowed. |
void |
setName(java.lang.String name)
Sets the name of this component. |
void |
setPageSize(int pgsz)
Sets the page size, aka., the number items per page. |
void |
setPaginal(Paginal pgi)
|
void |
setPreloadSize(int sz)
Sets the number of items to preload when receiving the rendering request from the client. |
void |
setRows(int rows)
Sets the rows. |
void |
setSelectedIndex(int jsel)
Deselects all of the currently selected items and selects the item with the given index. |
void |
setSelectedItem(Listitem item)
Deselects all of the currently selected items and selects the given item. |
void |
setSeltype(java.lang.String seltype)
Sets the seltype. |
void |
setTabindex(int tabindex)
Sets the tab order of this component. |
void |
setVflex(boolean vflex)
Sets whether to grow and shrink vertical to fit their given space, so called vertial flexibility. |
void |
smartUpdate(java.lang.String attr,
java.lang.String value)
|
void |
toggleItemSelection(Listitem item)
If the specified item is selected, it is deselected. |
| Methods inherited from class org.zkoss.zul.impl.XulElement |
|---|
getAction, getAllOnClickAttrs, getContext, getInnerAttrs, getPopup, getTooltip, setAction, setContext, setPopup, setTooltip |
| Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent |
|---|
addEventListener, appendAsapAttr, focus, getDraggable, getDroppable, getHeight, getLeft, getRealStyle, getRealStyleFlags, getSclass, getStyle, getTooltiptext, getTop, getWidth, getZIndex, isAsapRequired, removeEventListener, setClass, setDraggable, setDroppable, setLeft, setSclass, setStyle, setTooltiptext, setTop, setWidth, setZIndex |
| Methods inherited from class org.zkoss.zk.ui.AbstractComponent |
|---|
addAnnotation, addAnnotation, addEventHandler, addSharedAnnotationMap, addSharedEventHandlerMap, appendChild, applyProperties, containsVariable, detach, equals, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttributes, getAttributes, getChildren, getDefinition, getDesktop, getEventHandler, getExtraCtrl, getFellow, getFellowIfAny, getId, getListenerIterator, getMold, getMoldURI, getNamespace, getPage, getParent, getPropagatee, getRoot, getSpaceOwner, getUuid, getVariable, invalidate, isChildable, isListenerAvailable, isVisible, onDrawNewChild, onWrongValue, redraw, removeAttribute, removeAttribute, response, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setComponentDefinition, setId, setPage, setParent, setVariable, setVisible, smartUpdate, smartUpdate, toString, unsetVariable |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Listbox()
| Method Detail |
|---|
public Listhead getListhead()
Listhead belonging to this listbox, or null
if no list headers at all.
public Listfoot getListfoot()
Listfoot belonging to this listbox, or null
if no list footers at all.
public final boolean isCheckmark()
Default: false.
public void setCheckmark(boolean checkmark)
The check mark is a checkbox if isMultiple() returns
true. It is a radio button if isMultiple() returns false.
public final boolean isVflex()
Note: this attribute is ignored if setRows(int) is specified
Default: false.
public void setVflex(boolean vflex)
Note: this attribute is ignored if setRows(int) is specified
public final boolean isDisabled()
Default: false.
public void setDisabled(boolean disabled)
public int getTabindex()
Currently, only the "select" mold supports this property.
Default: -1 (means the same as browser's default).
public void setTabindex(int tabindex)
throws org.zkoss.zk.ui.WrongValueException
Currently, only the "select" mold supports this property.
org.zkoss.zk.ui.WrongValueExceptionpublic int getRows()
Default: 0.
public void setRows(int rows)
throws org.zkoss.zk.ui.WrongValueException
Note: if both setHeight(java.lang.String) is specified with non-empty,
setRows(int) is ignored
org.zkoss.zk.ui.WrongValueExceptionpublic java.lang.String getSeltype()
Default: "single".
public void setSeltype(java.lang.String seltype)
throws org.zkoss.zk.ui.WrongValueException
org.zkoss.zk.ui.WrongValueExceptionpublic boolean isMultiple()
Default: false.
public void setMultiple(boolean multiple)
public int getMaxlength()
public void setMaxlength(int maxlength)
public java.lang.String getName()
Default: null.
Don't use this method if your application is purely based on ZK's event-driven model.
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.
public void setName(java.lang.String name)
Don't use this method if your application is purely based on ZK's event-driven model.
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.
name - the name of this component.public java.util.List getItems()
Listitem.
By live we mean you can add or remove them directly with
the List interface. In other words, you could add or remove
an item by manipulating the returned list directly.
public int getItemCount()
public Listitem getItemAtIndex(int index)
Note: if live data is used (getModel() is not null),
the returned item might NOT be loaded yet.
To ensure it is loaded, you have to invoke renderItem(org.zkoss.zul.Listitem).
public int getIndexOfItem(Listitem item)
public int getSelectedIndex()
public void setSelectedIndex(int jsel)
public void selectItem(Listitem item)
It is the same as setSelectedItem(org.zkoss.zul.Listitem).
item - the item to select. If null, all items are deselected.public void addItemToSelection(Listitem item)
public void removeItemFromSelection(Listitem item)
public void toggleItemSelection(Listitem item)
public void clearSelection()
public void selectAll()
public Listitem getSelectedItem()
Note: if live data is used (getModel() is not null),
the returned item might NOT be loaded yet.
To ensure it is loaded, you have to invoke renderItem(org.zkoss.zul.Listitem).
public void setSelectedItem(Listitem item)
It is the same as selectItem(org.zkoss.zul.Listitem).
public java.util.Set getSelectedItems()
Note: if live data is used (getModel() is not null),
the returned item might NOT be loaded yet.
To ensure it is loaded, you have to invoke renderItem(org.zkoss.zul.Listitem).
public int getSelectedCount()
public Listitem appendItem(java.lang.String label,
java.lang.String value)
Note: if live data is used (getModel() is not null),
the returned item might NOT be loaded yet.
To ensure it is loaded, you have to invoke renderItem(org.zkoss.zul.Listitem).
public Listitem removeItemAt(int index)
Note: if live data is used (getModel() is not null),
the returned item might NOT be loaded yet.
To ensure it is loaded, you have to invoke renderItem(org.zkoss.zul.Listitem).
public Paginal getPaginal()
AbstractComponent.getMold() is "paging".
If mold is "paging", this method never returns null, because
a child paging controller is created automcatically (if not specified
by developers with setPaginal(org.zkoss.zul.ext.Paginal)).
If a paging controller is specified (either by setPaginal(org.zkoss.zul.ext.Paginal),
or by setMold(java.lang.String) with "paging"),
the listbox will rely on the paging controller to handle long-content
instead of scrolling.
public void setPaginal(Paginal pgi)
public void onPaging()
getPaginal()).
Default: re-render, if live data, and invalidate().
public Paging getPaging()
setPaginal(org.zkoss.zul.ext.Paginal).
public int getPageSize()
java.lang.IllegalStateException - if getPaginal() returns null,
i.e., mold is not "paging" and no external controller is specified.public void setPageSize(int pgsz)
java.lang.IllegalStateException - if getPaginal() returns null,
i.e., mold is not "paging" and no external controller is specified.public int getVisibleBegin()
Used only for component development, not for application developers.
public int getVisibleEnd()
Used only for component development, not for application developers.
public void smartUpdate(java.lang.String attr,
java.lang.String value)
smartUpdate in interface org.zkoss.zk.ui.ComponentsmartUpdate in class org.zkoss.zk.ui.AbstractComponentpublic void onChildAdded(org.zkoss.zk.ui.Component child)
onChildAdded in interface org.zkoss.zk.ui.ComponentonChildAdded in class org.zkoss.zk.ui.AbstractComponentpublic void onChildRemoved(org.zkoss.zk.ui.Component child)
onChildRemoved in interface org.zkoss.zk.ui.ComponentonChildRemoved in class org.zkoss.zk.ui.AbstractComponent
public boolean insertBefore(org.zkoss.zk.ui.Component newChild,
org.zkoss.zk.ui.Component refChild)
insertBefore in interface org.zkoss.zk.ui.ComponentinsertBefore in class org.zkoss.zk.ui.AbstractComponentpublic boolean removeChild(org.zkoss.zk.ui.Component child)
removeChild in interface org.zkoss.zk.ui.ComponentremoveChild in class org.zkoss.zk.ui.AbstractComponentpublic ListModel getModel()
public void setModel(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 ListitemRenderer getItemRenderer()
public void setItemRenderer(ListitemRenderer renderer)
getModel() is not null.
Note: changing a render will not cause the listbox 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 model
public void setItemRenderer(java.lang.String clsnm)
throws java.lang.ClassNotFoundException,
java.lang.NoSuchMethodException,
java.lang.InstantiationException,
java.lang.reflect.InvocationTargetException
java.lang.ClassNotFoundException
java.lang.NoSuchMethodException
java.lang.InstantiationException
java.lang.reflect.InvocationTargetExceptionpublic int getPreloadSize()
Default: 7.
It is used only if live data (setModel(org.zkoss.zul.ListModel) and
not paging (getPaging().
public void setPreloadSize(int sz)
It is used only if live data (setModel(org.zkoss.zul.ListModel) and
not paging (getPaging().
sz - the number of items to preload. If zero, no preload
at all.
org.zkoss.zk.ui.UiException - if sz is negativepublic void onInitRender()
public Listitem renderItem(Listitem li)
Listitem if not loaded yet,
with getItemRenderer().
It does nothing if getModel() returns null.
In other words, it is meaningful only if live data model is used.
renderItems(java.util.Set),
renderAll()public void renderAll()
Listitem if not loaded yet,
with getItemRenderer().
renderItem(org.zkoss.zul.Listitem),
renderItems(java.util.Set)public void renderItems(java.util.Set items)
public void setMold(java.lang.String mold)
setMold in interface org.zkoss.zk.ui.ComponentsetMold in class org.zkoss.zk.ui.AbstractComponentpublic void setHeight(java.lang.String height)
setHeight in class org.zkoss.zk.ui.HtmlBasedComponentpublic java.lang.String getOuterAttrs()
getOuterAttrs in class XulElementpublic java.lang.Object clone()
clone in interface org.zkoss.zk.ui.Componentclone in class org.zkoss.zk.ui.AbstractComponentprotected java.lang.Object newExtraCtrl()
newExtraCtrl in class org.zkoss.zk.ui.HtmlBasedComponent
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||