org.zkoss.zul
Class Combobox

java.lang.Object
  extended by org.zkoss.zk.ui.AbstractComponent
      extended by org.zkoss.zk.ui.HtmlBasedComponent
          extended by org.zkoss.zul.impl.XulElement
              extended by org.zkoss.zul.impl.InputElement
                  extended by org.zkoss.zul.Textbox
                      extended by org.zkoss.zul.Combobox
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, org.zkoss.zk.ui.Component, org.zkoss.zk.ui.sys.ComponentCtrl, Constrainted

public class Combobox
extends Textbox

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.getSclass(): combobox.

Events: onOpen
Developers can listen to the onOpen event and initializes it when OpenEvent.isOpen() is true, and/or clean up if false.

Note: to have better performance, onOpen is sent only if a non-deferrable event listener is registered (see Deferrable).

Author:
tomyeh
See Also:
Comboitem, Serialized Form

Nested Class Summary
protected  class Combobox.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
Combobox()
           
Combobox(java.lang.String value)
           
 
Method Summary
 Comboitem appendItem(java.lang.String label)
          Appends an item.
 java.lang.String getImage()
          Returns the URI of the button image.
 java.lang.String getInnerAttrs()
          Generates the Client-Side-Action attributes to the interior tag.
 Comboitem getItemAtIndex(int index)
          Returns the item at the specified index.
 int getItemCount()
          Returns the number of items.
 java.util.List getItems()
          Returns a 'live' list of all Comboitem.
 java.lang.String getOuterAttrs()
           
protected  int getRealStyleFlags()
          Returns RS_NO_WIDTH|RS_NO_HEIGHT.
 Comboitem getSelectedItem()
          Returns the selected item, or null if no matched.
 boolean insertBefore(org.zkoss.zk.ui.Component newChild, org.zkoss.zk.ui.Component refChild)
           
 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.
 boolean isChildable()
          Childable.
protected  java.lang.Object newExtraCtrl()
           
 void onChildAdded(org.zkoss.zk.ui.Component child)
           
 void onChildRemoved(org.zkoss.zk.ui.Component child)
           
 Comboitem removeItemAt(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 setImage(java.lang.String img)
          Sets the URI of the button image.
 void setMultiline(boolean multiline)
          Sets whether it is multiline.
 void setRows(int rows)
          Sets the rows.
 
Methods inherited from class org.zkoss.zul.Textbox
coerceFromString, coerceToString, getRows, getType, getValue, isMultiline, setType, setValue
 
Methods inherited from class org.zkoss.zul.impl.InputElement
checkUserError, clearErrorMessage, getAreaText, getCols, getConstraint, getErrorMessage, getMaxlength, getName, getRawText, getRawValue, getTabindex, getTargetValue, getText, isAsapRequired, isDisabled, isReadonly, isValid, onWrongValue, select, setCols, setConstraint, setConstraint, setDisabled, setMaxlength, setName, setRawValue, setReadonly, setSelectedText, setSelectionRange, setTabindex, setText, showCustomError, validate
 
Methods inherited from class org.zkoss.zul.impl.XulElement
getAction, getAllOnClickAttrs, getContext, getPopup, getTooltip, setAction, setContext, setPopup, setTooltip
 
Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
addEventListener, appendAsapAttr, focus, getDraggable, getDroppable, getHeight, getLeft, getRealStyle, getSclass, getStyle, getTooltiptext, getTop, getWidth, getZIndex, removeEventListener, setClass, setDraggable, setDroppable, setHeight, setLeft, setSclass, setStyle, setTooltiptext, setTop, setWidth, setZIndex
 
Methods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addAnnotation, addEventHandler, addSharedAnnotationMap, addSharedEventHandlerMap, appendChild, applyProperties, clone, 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, isListenerAvailable, isVisible, onDrawNewChild, redraw, removeAttribute, removeAttribute, removeChild, response, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setComponentDefinition, setId, setMold, setPage, setParent, setVariable, setVisible, smartUpdate, smartUpdate, smartUpdate, toString, unsetVariable
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Combobox

public Combobox()

Combobox

public Combobox(java.lang.String value)
         throws org.zkoss.zk.ui.WrongValueException
Throws:
org.zkoss.zk.ui.WrongValueException
Method Detail

isAutodrop

public boolean isAutodrop()
Returns whether to automatically drop the list if users is changing this text box.

Default: false.


setAutodrop

public void setAutodrop(boolean autodrop)
Sets whether to automatically drop the list if users is changing this text box.


isAutocomplete

public boolean isAutocomplete()
Returns whether to automatically complete this text box by matching the nearest item (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.


setAutocomplete

public void setAutocomplete(boolean autocomplete)
Sets whether to automatically complete this text box by matching the nearest item (Comboitem.


isButtonVisible

public boolean isButtonVisible()
Returns whether the button (on the right of the textbox) is visible.

Default: true.


setButtonVisible

public void setButtonVisible(boolean visible)
Sets whether the button (on the right of the textbox) is visible.


getImage

public java.lang.String getImage()
Returns the URI of the button image.

Since:
2.4.1

setImage

public void setImage(java.lang.String img)
Sets the URI of the button image.

Parameters:
img - the URI of the button image. If null or empty, the default URI is used.
Since:
2.4.1

getItems

public java.util.List getItems()
Returns a 'live' list of all Comboitem. By live we mean you can add or remove them directly with the List interface.

Currently, it is the same as AbstractComponent.getChildren(). However, we might add other kind of children in the future.


getItemCount

public int getItemCount()
Returns the number of items.


getItemAtIndex

public Comboitem getItemAtIndex(int index)
Returns the item at the specified index.


appendItem

public Comboitem appendItem(java.lang.String label)
Appends an item.


removeItemAt

public Comboitem removeItemAt(int index)
Removes the child item in the list box at the given index.

Returns:
the removed item.

getSelectedItem

public Comboitem getSelectedItem()
Returns the selected item, or null if no matched.

By selected we mean the first Comboitem whose label (LabelElement.getLabel()) equals with Textbox.getValue(). It is usually used with Comboitem.getValue().

The combobox may contain any value, so there may be no match at all.

Since:
2.4.0
See Also:
Comboitem.getValue()

setMultiline

public void setMultiline(boolean multiline)
Description copied from class: Textbox
Sets whether it is multiline.

Overrides:
setMultiline in class Textbox

setRows

public void setRows(int rows)
Description copied from class: Textbox
Sets the rows.

Overrides:
setRows in class Textbox

getOuterAttrs

public java.lang.String getOuterAttrs()
Overrides:
getOuterAttrs in class Textbox

getInnerAttrs

public java.lang.String getInnerAttrs()
Description copied from class: XulElement
Generates the Client-Side-Action attributes to the interior tag. Reason: onfocus is the main use.

Overrides:
getInnerAttrs in class Textbox

getRealStyleFlags

protected int getRealStyleFlags()
Returns RS_NO_WIDTH|RS_NO_HEIGHT.

Overrides:
getRealStyleFlags in class org.zkoss.zk.ui.HtmlBasedComponent

insertBefore

public boolean insertBefore(org.zkoss.zk.ui.Component newChild,
                            org.zkoss.zk.ui.Component refChild)
Specified by:
insertBefore in interface org.zkoss.zk.ui.Component
Overrides:
insertBefore in class org.zkoss.zk.ui.AbstractComponent

isChildable

public boolean isChildable()
Childable.

Specified by:
isChildable in interface org.zkoss.zk.ui.Component
Overrides:
isChildable in class InputElement

onChildAdded

public void onChildAdded(org.zkoss.zk.ui.Component child)
Specified by:
onChildAdded in interface org.zkoss.zk.ui.Component
Overrides:
onChildAdded in class org.zkoss.zk.ui.AbstractComponent

onChildRemoved

public void onChildRemoved(org.zkoss.zk.ui.Component child)
Specified by:
onChildRemoved in interface org.zkoss.zk.ui.Component
Overrides:
onChildRemoved in class org.zkoss.zk.ui.AbstractComponent

newExtraCtrl

protected java.lang.Object newExtraCtrl()
Overrides:
newExtraCtrl in class InputElement


Copyright © 2005-2007 Potix Corporation. All Rights Reserved.