Package org.zkoss.zul

Class Selectbox

java.lang.Object
org.zkoss.zk.ui.AbstractComponent
org.zkoss.zk.ui.HtmlBasedComponent
org.zkoss.zul.Selectbox
All Implemented Interfaces:
Serializable, Cloneable, org.zkoss.zk.ui.Component, org.zkoss.zk.ui.ext.Disable, org.zkoss.zk.ui.ext.Scope, org.zkoss.zk.ui.sys.ComponentCtrl

public class Selectbox extends org.zkoss.zk.ui.HtmlBasedComponent implements org.zkoss.zk.ui.ext.Disable
A light weight dropdown list.

Default getZclass(): z-selectbox. It does not create child widgets for each data, so the memory usage is much lower at the server. However, the implementation is based on HTML SELECT and OPTION tags, so the functionality is not as rich as Listbox.

Since:
6.0.0
Author:
jumperchen
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected class 
    A utility class to implement HtmlBasedComponent.getExtraCtrl().

    Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent

    org.zkoss.zk.ui.AbstractComponent.Children, org.zkoss.zk.ui.AbstractComponent.ForwardInfo, org.zkoss.zk.ui.AbstractComponent.TargetInfo
  • Field Summary

    Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent

    _zclass

    Fields inherited from interface org.zkoss.zk.ui.Component

    APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE

    Fields 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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
     
    <T> ItemRenderer<T>
    Returns the renderer to render each item, or null if the default renderer is used.
    <T> ListModel<T>
    Returns the model associated with this selectbox, or null if this selectbox is not associated with any list data model.
    Returns the name of this component.
    <T> ItemRenderer<T>
     
    int
    Returns the index of the selected item (-1 if no one is selected).
     
    void
     
    protected boolean
     
    boolean
    Returns whether it is disabled.
    void
     
    void
     
    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
    setDisabled(boolean disabled)
    Sets whether it is disabled.
    void
    Sets the renderer by use of a class name.
    void
    Sets the renderer which is used to render each item if getModel() is not null.
    void
    setModel(ListModel<?> model)
    Sets the list model associated with this selectbox.
    void
    Sets the name of this component.
    void
    setParent(org.zkoss.zk.ui.Component parent)
     
    void
    setSelectedIndex(int jsel)
    Selects the item with the given index.

    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, setZIndexDirectly

    Methods 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, 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

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Selectbox

      public Selectbox()
  • Method Details

    • getZclass

      public String getZclass()
      Overrides:
      getZclass in class org.zkoss.zk.ui.HtmlBasedComponent
    • getSelectedIndex

      public int getSelectedIndex()
      Returns the index of the selected item (-1 if no one is selected).
    • setSelectedIndex

      public void setSelectedIndex(int jsel)
      Selects the item with the given index.
    • getItemRenderer

      public <T> ItemRenderer<T> getItemRenderer()
      Returns the renderer to render each item, or null if the default renderer is used.
    • setItemRenderer

      public void setItemRenderer(ItemRenderer<?> renderer)
      Sets the renderer which is used to render each item if getModel() is not null.

      Note: changing a render will not cause the selectbox to re-render. If you want it to re-render, you could assign the same model again (i.e., setModel(null) and than setModel(oldModel)), or fire an ListDataEvent event.

      Parameters:
      renderer - the renderer, or null to use the default.
      Throws:
      org.zkoss.zk.ui.UiException - if failed to initialize with the model
    • setItemRenderer

      Sets the renderer by use of a class name. It creates an instance automatically.
      Throws:
      ClassNotFoundException
      NoSuchMethodException
      IllegalAccessException
      InstantiationException
      InvocationTargetException
    • isDisabled

      public boolean isDisabled()
      Returns whether it is disabled.

      Default: false.

      Specified by:
      isDisabled in interface org.zkoss.zk.ui.ext.Disable
    • isChildable

      protected boolean isChildable()
      Overrides:
      isChildable in class org.zkoss.zk.ui.AbstractComponent
    • setDisabled

      public void setDisabled(boolean disabled)
      Sets whether it is disabled.
      Specified by:
      setDisabled in interface org.zkoss.zk.ui.ext.Disable
    • getName

      public String 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

      public void setName(String name)
      Sets the name 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.
    • setModel

      public void setModel(ListModel<?> model)
      Sets the list model associated with this selectbox. 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 dissociate any previous model.
      Throws:
      org.zkoss.zk.ui.UiException - if failed to initialize with the model
    • onInitRender

      public void onInitRender()
    • onInitRenderNow

      public void onInitRenderNow()
    • getModel

      public <T> ListModel<T> getModel()
      Returns the model associated with this selectbox, or null if this selectbox is not associated with any list data model.
    • getRealRenderer

      public <T> ItemRenderer<T> getRealRenderer()
    • invalidate

      public void invalidate()
      Specified by:
      invalidate in interface org.zkoss.zk.ui.Component
      Overrides:
      invalidate in class org.zkoss.zk.ui.AbstractComponent
    • setParent

      public void setParent(org.zkoss.zk.ui.Component parent)
      Specified by:
      setParent in interface org.zkoss.zk.ui.Component
      Overrides:
      setParent in class org.zkoss.zk.ui.AbstractComponent
    • onPageAttached

      public void onPageAttached(org.zkoss.zk.ui.Page newpage, org.zkoss.zk.ui.Page oldpage)
      Specified by:
      onPageAttached in interface org.zkoss.zk.ui.sys.ComponentCtrl
      Overrides:
      onPageAttached in class org.zkoss.zk.ui.AbstractComponent
    • onPageDetached

      public void onPageDetached(org.zkoss.zk.ui.Page page)
      Specified by:
      onPageDetached in interface org.zkoss.zk.ui.sys.ComponentCtrl
      Overrides:
      onPageDetached in class org.zkoss.zk.ui.AbstractComponent
    • renderProperties

      protected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) throws IOException
      Overrides:
      renderProperties in class org.zkoss.zk.ui.HtmlBasedComponent
      Throws:
      IOException
    • service

      public void service(org.zkoss.zk.au.AuRequest request, boolean everError)
      Specified by:
      service in interface org.zkoss.zk.ui.sys.ComponentCtrl
      Overrides:
      service in class org.zkoss.zk.ui.HtmlBasedComponent
    • clone

      public Object clone()
      Specified by:
      clone in interface org.zkoss.zk.ui.Component
      Overrides:
      clone in class org.zkoss.zk.ui.HtmlBasedComponent
    • sessionWillPassivate

      public void sessionWillPassivate(org.zkoss.zk.ui.Page page)
      Specified by:
      sessionWillPassivate in interface org.zkoss.zk.ui.sys.ComponentCtrl
      Overrides:
      sessionWillPassivate in class org.zkoss.zk.ui.AbstractComponent
    • sessionDidActivate

      public void sessionDidActivate(org.zkoss.zk.ui.Page page)
      Specified by:
      sessionDidActivate in interface org.zkoss.zk.ui.sys.ComponentCtrl
      Overrides:
      sessionDidActivate in class org.zkoss.zk.ui.AbstractComponent
    • getExtraCtrl

      public Object getExtraCtrl()
      Specified by:
      getExtraCtrl in interface org.zkoss.zk.ui.sys.ComponentCtrl
      Overrides:
      getExtraCtrl in class org.zkoss.zk.ui.HtmlBasedComponent