org.zkoss.zul
Class Selectbox

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

public class Selectbox
extends org.zkoss.zk.ui.HtmlBasedComponent

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:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.zkoss.zk.ui.HtmlBasedComponent
org.zkoss.zk.ui.HtmlBasedComponent.ExtraCtrl
 
Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent
org.zkoss.zk.ui.AbstractComponent.Children
 
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
CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE
 
Constructor Summary
Selectbox()
           
 
Method Summary
 Object clone()
           
<T> ItemRenderer<T>
getItemRenderer()
          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 selectbox, or null if this selectbox is not associated with any list data model.
 String getName()
          Returns the name of this component.
<T> ItemRenderer<T>
getRealRenderer()
           
 int getSelectedIndex()
          Returns the index of the selected item (-1 if no one is selected).
 int getTabindex()
          Returns the tab order of this component.
 String getZclass()
           
 void invalidate()
           
protected  boolean isChildable()
           
 boolean isDisabled()
          Returns whether it is disabled.
 void onInitRender()
           
 void onInitRenderNow()
           
 void onPageAttached(org.zkoss.zk.ui.Page newpage, org.zkoss.zk.ui.Page oldpage)
           
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 setItemRenderer(ItemRenderer<?> renderer)
          Sets the renderer which is used to render each item if getModel() is not null.
 void setItemRenderer(String clsnm)
          Sets the renderer by use of a class name.
 void setModel(ListModel<?> model)
          Sets the list model associated with this selectbox.
 void setName(String name)
          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.
 void setTabindex(int tabindex)
          Sets the tab order of this component.
 
Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
focus, getAction, getDraggable, getDroppable, getExtraCtrl, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getStyle, getTooltiptext, getTop, getVflex, getWidth, getZindex, getZIndex, setAction, setClass, setDraggable, setDroppable, setFocus, setHeight, setHeightDirectly, setHflex, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, setStyle, setTooltiptext, setTop, setTopDirectly, setVflex, setWidth, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectly
 
Methods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addAnnotation, addClientEvent, addEventHandler, addEventListener, addEventListener, addForward, addForward, addForward, addForward, addMoved, addScopeListener, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildAdded, beforeChildRemoved, beforeParentChanged, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableClientUpdate, equals, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotation, getAnnotations, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getAutag, getChildren, getClientEvents, getDefaultMold, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getEventListenerMap, getEventListeners, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getId, getLastChild, getListenerIterator, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getRoot, getSpaceOwner, getStubonly, getTemplate, getTemplateNames, getUuid, getWidgetAttribute, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasFellow, hasFellow, insertBefore, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onChildRemoved, onPageDetached, onWrongValue, query, queryAll, redraw, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeChild, removeEventListener, removeForward, removeForward, removeScopeListener, render, render, render, replace, response, response, response, service, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setDefinition, setDefinition, setId, setMold, setPage, setPageBefore, setStubonly, setStubonly, setTemplate, setVisible, setVisibleDirectly, setWidgetAttribute, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateByClient, willPassivate, willPassivate, willSerialize, willSerialize
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Selectbox

public Selectbox()
Method Detail

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.


getTabindex

public int getTabindex()
Returns the tab order of this component.

Default: 0 (means the same as browser's default).


setTabindex

public void setTabindex(int tabindex)
                 throws org.zkoss.zk.ui.WrongValueException
Sets the tab order of this component.

Throws:
org.zkoss.zk.ui.WrongValueException

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

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.

Throws:
ClassNotFoundException
NoSuchMethodException
IllegalAccessException
InstantiationException
InvocationTargetException

isDisabled

public boolean isDisabled()
Returns whether it is disabled.

Default: false.


isChildable

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

setDisabled

public void setDisabled(boolean disabled)
Sets whether it is disabled.


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

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


Copyright © 2013. All rights reserved.