Package org.zkoss.zul
Class Radiogroup
- java.lang.Object
-
- org.zkoss.zk.ui.AbstractComponent
-
- org.zkoss.zk.ui.HtmlBasedComponent
-
- org.zkoss.zul.impl.XulElement
-
- org.zkoss.zul.Radiogroup
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.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 Radiogroup extends XulElement implements org.zkoss.zk.ui.ext.Disable
A radio group.Note: To support the versatile layout, a radio group accepts any kind of children, including
Radio
. On the other hand, the parent of a radio, if any, must be a radio group.- Author:
- tomyeh
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Radiogroup()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Radio
appendItem(java.lang.String label, java.lang.String value)
Appends a radio button.java.lang.Object
clone()
Radio
getItemAtIndex(int index)
Returns the radio button at the specified index.int
getItemCount()
Returns the number of radio buttons in this group.java.util.List<Radio>
getItems()
Returns a readonly list ofRadio
.<T> ListModel<T>
getModel()
Returns the list model associated with this radiogroup, or null if this radiogroup is not associated with any list data model.java.lang.String
getName()
Returns the name of this group of radio buttons.java.lang.String
getOrient()
Returns the orient.<T> RadioRenderer<T>
getRadioRenderer()
Returns the renderer to render each radio, or null if the default renderer is used.int
getSelectedIndex()
Returns the index of the selected radio button (-1 if no one is selected).Radio
getSelectedItem()
Returns the selected radio button.boolean
isDisabled()
Returns whether it is disabled.void
onChildAdded(org.zkoss.zk.ui.Component child)
void
onInitRender(org.zkoss.zk.ui.event.Event data)
For model renderingvoid
onPageAttached(org.zkoss.zk.ui.Page newpage, org.zkoss.zk.ui.Page oldpage)
void
onPageDetached(org.zkoss.zk.ui.Page page)
Radio
removeItemAt(int index)
Removes the child radio button in the radio group at the given index.protected void
renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer)
void
setDisabled(boolean disabled)
Sets whether the radiogroup is disabled.void
setModel(ListModel<?> model)
Sets the list model associated with this radiogroup.void
setName(java.lang.String name)
Sets the name of this group of radio buttons.void
setOrient(java.lang.String orient)
Sets the orient.void
setRadioRenderer(java.lang.String clsnm)
Sets the renderer by use of a class name.void
setRadioRenderer(RadioRenderer<?> renderer)
Sets the renderer which is used to render each row ifgetModel()
is not null.void
setSelectedIndex(int jsel)
Deselects all of the currently selected radio button and selects the radio button with the given index.void
setSelectedItem(Radio item)
Deselects all of the currently selected radio buttons and selects the given radio button.-
Methods inherited from class org.zkoss.zul.impl.XulElement
getContext, getCtrlKeys, getPopup, getPropertyAccess, getTooltip, setContext, setContext, setContextAttributes, setCtrlKeys, setPopup, setPopup, setPopupAttributes, setTooltip, setTooltip, setTooltipAttributes
-
Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
addSclass, evalCSSFlex, focus, getAction, getClientAction, getDraggable, getDroppable, getExtraCtrl, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getStyle, getTabindex, getTabindexInteger, getTooltiptext, getTop, getVflex, getWidth, getZclass, getZindex, getZIndex, removeSclass, removeSclass, service, setAction, setClass, setClientAction, setDraggable, setDroppable, setFocus, setHeight, setHeight0, setHeightDirectly, setHflex, setHflex0, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, 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, 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, getAnnotation, getAnnotations, 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, getListenerIterator, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getRedrawCallback, getRoot, getShadowFellowIfAny, getShadowRoots, getShadowVariable, getShadowVariable, getShadowVariable0, getSpaceOwner, getSpecialRendererOutput, getStubonly, getSubBindingAnnotationCount, getTemplate, getTemplateNames, getUuid, getWidgetAttribute, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasBindingAnnotation, hasFellow, hasFellow, hasSubBindingAnnotation, initIndexCacheMap, insertBefore, invalidate, invalidatePartial, isChildable, isDisabledHostChanged, isInitialized, isInvalidated, isListenerAvailable, isVisible, 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, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setClientAttribute, setClientDataAttribute, setDefinition, setDefinition, setId, setMold, setPage, setPageBefore, setParent, setStubonly, setStubonly, setSubBindingAnnotationCount, setTemplate, setVisible, setVisibleDirectly, setWidgetAttribute, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateByClient, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerialize
-
-
-
-
Method Detail
-
getOrient
public java.lang.String getOrient()
Returns the orient.Default: "horizontal".
-
setOrient
public void setOrient(java.lang.String orient) throws org.zkoss.zk.ui.WrongValueException
Sets the orient.- Parameters:
orient
- either "horizontal" or "vertical".- Throws:
org.zkoss.zk.ui.WrongValueException
-
getItems
public java.util.List<Radio> getItems()
Returns a readonly list ofRadio
. Note: any update to the list won't affect the state of this radio group.- Since:
- 5.0.4
-
getItemAtIndex
public Radio getItemAtIndex(int index)
Returns the radio button at the specified index.
-
getItemCount
public int getItemCount()
Returns the number of radio buttons in this group.
-
getSelectedIndex
public int getSelectedIndex()
Returns the index of the selected radio button (-1 if no one is selected). Note: The index of the external radio button could be unintuitive since radio group always count descendant radio before external radio.
-
setSelectedIndex
public void setSelectedIndex(int jsel)
Deselects all of the currently selected radio button and selects the radio button with the given index.
-
getSelectedItem
public Radio getSelectedItem()
Returns the selected radio button.
-
setSelectedItem
public void setSelectedItem(Radio item)
Deselects all of the currently selected radio buttons and selects the given radio button.
-
appendItem
public Radio appendItem(java.lang.String label, java.lang.String value)
Appends a radio button.
-
removeItemAt
public Radio removeItemAt(int index)
Removes the child radio button in the radio group at the given index.- Returns:
- the removed radio button.
-
getName
public java.lang.String getName()
Returns the name of this group of radio buttons. All child radio buttons shared the same name (Radio.getName()
).Default: automatically generated a unique name
Don't use this method if your application is purely based on ZK's event-driven model.
-
setName
public void setName(java.lang.String name)
Sets the name of this group of radio buttons. All child radio buttons shared the same name (Radio.getName()
).Don't use this method if your application is purely based on ZK's event-driven model.
-
isDisabled
public boolean isDisabled()
Returns whether it is disabled.Default: false.
- Specified by:
isDisabled
in interfaceorg.zkoss.zk.ui.ext.Disable
- Since:
- 9.6.0
-
setDisabled
public void setDisabled(boolean disabled)
Sets whether the radiogroup is disabled. All the radios belong to this radiogroup will be set to disabled or not disabled as well. Notice: Once a radio is added to a disabled radiogroup (including external radio), the radio will be set to disabled too.- Specified by:
setDisabled
in interfaceorg.zkoss.zk.ui.ext.Disable
- Parameters:
disabled
- whether the radiogroup is disabled- Since:
- 9.6.0
-
renderProperties
protected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) throws java.io.IOException
- Overrides:
renderProperties
in classXulElement
- Throws:
java.io.IOException
-
getModel
public <T> ListModel<T> getModel()
Returns the list model associated with this radiogroup, or null if this radiogroup is not associated with any list data model.- Since:
- 6.0.0
-
setModel
public void setModel(ListModel<?> model)
Sets the list model associated with this radiogroup. 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 dis-associate any previous model.- Throws:
org.zkoss.zk.ui.UiException
- if failed to initialize with the model- Since:
- 6.0.0
-
onInitRender
public void onInitRender(org.zkoss.zk.ui.event.Event data)
For model rendering- Parameters:
data
-
-
getRadioRenderer
public <T> RadioRenderer<T> getRadioRenderer()
Returns the renderer to render each radio, or null if the default renderer is used.- Since:
- 6.0.0
-
setRadioRenderer
public void setRadioRenderer(RadioRenderer<?> renderer)
Sets the renderer which is used to render each row ifgetModel()
is not null.Note: changing a render will not cause the radiogroup 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.- Parameters:
renderer
- the renderer, or null to use the default.- Throws:
org.zkoss.zk.ui.UiException
- if failed to initialize with the model- Since:
- 6.0.0
-
setRadioRenderer
public void setRadioRenderer(java.lang.String clsnm) throws java.lang.ClassNotFoundException, java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.reflect.InvocationTargetException
Sets the renderer by use of a class name. It creates an instance automatically.- Throws:
java.lang.ClassNotFoundException
java.lang.NoSuchMethodException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.lang.reflect.InvocationTargetException
- Since:
- 6.0.0
-
clone
public java.lang.Object clone()
- Specified by:
clone
in interfaceorg.zkoss.zk.ui.Component
- Overrides:
clone
in classXulElement
-
onPageAttached
public void onPageAttached(org.zkoss.zk.ui.Page newpage, org.zkoss.zk.ui.Page oldpage)
- Specified by:
onPageAttached
in interfaceorg.zkoss.zk.ui.sys.ComponentCtrl
- Overrides:
onPageAttached
in classorg.zkoss.zk.ui.AbstractComponent
-
onPageDetached
public void onPageDetached(org.zkoss.zk.ui.Page page)
- Specified by:
onPageDetached
in interfaceorg.zkoss.zk.ui.sys.ComponentCtrl
- Overrides:
onPageDetached
in classorg.zkoss.zk.ui.AbstractComponent
-
onChildAdded
public void onChildAdded(org.zkoss.zk.ui.Component child)
- Specified by:
onChildAdded
in interfaceorg.zkoss.zk.ui.sys.ComponentCtrl
- Overrides:
onChildAdded
in classorg.zkoss.zk.ui.AbstractComponent
-
-