Package org.zkoss.zul

Class Radiogroup

All Implemented Interfaces:
Serializable, Cloneable, Component, Disable, Scope, ComponentCtrl

public class Radiogroup extends XulElement implements 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:
  • Constructor Details

    • Radiogroup

      public Radiogroup()
  • Method Details

    • getOrient

      public String getOrient()
      Returns the orient.

      Default: "horizontal".

    • setOrient

      public void setOrient(String orient) throws WrongValueException
      Sets the orient.
      Parameters:
      orient - either "horizontal" or "vertical".
      Throws:
      WrongValueException
    • getItems

      public List<Radio> getItems()
      Returns a readonly list of Radio. 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(String label, 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 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(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 interface 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 interface Disable
      Parameters:
      disabled - whether the radiogroup is disabled
      Since:
      9.6.0
    • renderProperties

      protected void renderProperties(ContentRenderer renderer) throws IOException
      Description copied from class: HtmlBasedComponent
      Renders the content of this component, excluding the enclosing tags and children.

      See also ZK Client-side Reference: Property Rendering

      Overrides:
      renderProperties in class XulElement
      Throws:
      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:
      UiException - if failed to initialize with the model
      Since:
      6.0.0
    • onInitRender

      public void onInitRender(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 if getModel() 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:
      UiException - if failed to initialize with the model
      Since:
      6.0.0
    • setRadioRenderer

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

      public Object clone()
      Description copied from interface: Component
      Clones the component. All of its children and descendants are cloned. Also, ID are preserved.
      Specified by:
      clone in interface Component
      Overrides:
      clone in class XulElement
      Returns:
      the new component. Notice that it doesn't belong to any page, nor desktop. It doesn't have a parent, either.
    • service

      public void service(AuRequest request, boolean everError)
      Processes an AU request.
      Specified by:
      service in interface ComponentCtrl
      Overrides:
      service in class HtmlBasedComponent
      everError - whether any error ever occurred before processing this request.
      Since:
      10.0.0
      See Also:
    • onPageAttached

      public void onPageAttached(Page newpage, Page oldpage)
      Description copied from class: AbstractComponent
      Default: handles special event listeners.
      Specified by:
      onPageAttached in interface ComponentCtrl
      Overrides:
      onPageAttached in class AbstractComponent
      Parameters:
      newpage - the new page (never null).
      oldpage - the previous page, if any, or null if it didn't belong to any page.
      See Also:
    • onPageDetached

      public void onPageDetached(Page page)
      Description copied from class: AbstractComponent
      Default: handles special event listeners.
      Specified by:
      onPageDetached in interface ComponentCtrl
      Overrides:
      onPageDetached in class AbstractComponent
      Parameters:
      page - the previous page (never null)
      See Also:
    • onChildAdded

      public void onChildAdded(Component child)
      Description copied from class: AbstractComponent
      Default: handles special event listeners.
      Specified by:
      onChildAdded in interface ComponentCtrl
      Overrides:
      onChildAdded in class AbstractComponent
      See Also: