Interface IRadiogroup<I extends IAnyGroup>

  • All Superinterfaces:
    IAnyGroup<IRadiogroup<I>>, IChildable<IRadiogroup<I>,​I>, IComponent<IRadiogroup<I>>, IDisable<IRadiogroup<I>>, IHtmlBasedComponent<IRadiogroup<I>>, IXulElement<IRadiogroup<I>>

    public interface IRadiogroup<I extends IAnyGroup>
    extends IXulElement<IRadiogroup<I>>, IChildable<IRadiogroup<I>,​I>, IAnyGroup<IRadiogroup<I>>, IDisable<IRadiogroup<I>>
    Immutable Radiogroup component

    A radio group.

    Note: To support the versatile layout, a radio group accepts any kind of children, including IRadio. On the other hand, the parent of a radio, if any, must be a radio group.

    Example

     @RichletMapping("/example")
     public IComponent example() {
         return IWindow.ofTitle("Radiobox & Radio Demo").withWidth("400px")
             .withBorder("normal").withChildren(
                 IVlayout.of(IRadiogroup.of(
                     IRadio.of("Apple"),
                     IRadio.of("Orange"),
                     IRadio.of("Banana")
                 ).withAction(this::doRadioCheck),
                 ILabel.of(" You have selected :"),
                 ILabel.ofId("fruit").withStyle("color:red")
             )
         );
     }
     @Action(type = Events.ON_CHECK)
     public void doRadioCheck(UiAgent uiAgent, @ActionVariable(targetId = ActionTarget.SELF,
         field = "selectedItem.label") String label) {
             uiAgent.smartUpdate(Locator.ofId("fruit"), new ILabel.Updater().value(label));
     }
     

    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.

    Radiogroup as an Ancestor of Radio

    Groups radio components into the same radiogroup if they share the same ancestor, not just direct parent. It allows a more sophisticated layout. For example,

     @RichletMapping("/example/ancestor")
     public IComponent ancestorExample() {
         return IRadiogroup.of(
             IVlayout.of(
                 IHlayout.of(
                     IRadio.of("radio 1"),
                     IRadio.of("radio 2"),
                     IRadio.of("radio 3")
                 ), IHlayout.of(
                     IRadio.of("radio 4"),
                     IRadio.of("radio 5"),
                     IRadio.of("radio 6")
                 )
             )
         );
     }
     

    A Row of a Grid as a Radio Group

    Sometimes it is not possible to make the radiogroup component as an ancestor of all radio components. For example, each row of a grid might be an independent group. To solve this, you have to assign the radiogroup component to the radio component explicitly by the use of IRadio.withRadiogroup(String).

     @RichletMapping("/example/grid")
     public IComponent gridExample() {
         return IDiv.of(
             IRadiogroup.ofId("popular"),
             IRadiogroup.ofId("fun"),
             IGrid.of(
                 IRow.of(
                     ILabel.of("Most popular"),
                     IRadio.of("Java").withRadiogroup("popular"),
                     IRadio.of("Groovy").withRadiogroup("popular"),
                     IRadio.of("C#").withRadiogroup("popular"),
                     ITextbox.DEFAULT
                 ),
                 IRow.of(
                     ILabel.of("Most fun"),
                     IRadio.of("Open Source").withRadiogroup("fun"),
                     IRadio.of("Social Networking").withRadiogroup("fun"),
                     IRadio.of("Searching").withRadiogroup("fun"),
                     ITextbox.DEFAULT
                 )
             )
         );
     }
     
    Author:
    katherine
    See Also:
    Radiogroup
    • Field Detail

      • DEFAULT

        static final IRadiogroup<IAnyGroup> DEFAULT
        Constant for default attributes of this immutable component.
    • Method Detail

      • getWidgetClass

        default java.lang.String getWidgetClass()
        Returns the client widget class.

        Default: "zul.wgt.Radiogroup"

        Specified by:
        getWidgetClass in interface IComponent<I extends IAnyGroup>
      • getOrient

        default java.lang.String getOrient()
        Returns the orient.

        Default: "horizontal".

      • withOrient

        IRadiogroup<I> withOrient​(java.lang.String orient)
        Returns a copy of this immutable component with the specified orient.

        Sets the orient of component

        Parameters:
        orient - Either "horizontal" or "vertical"

        Default: "horizontal".

        Returns:
        A modified copy of the this object
      • withOrient

        default IRadiogroup<I> withOrient​(IRadiogroup.Orient orient)
        Returns a copy of this immutable component with the specified orient.

        Sets the orient of component

        Parameters:
        orient - The orient

        Default: "horizontal".

        Returns:
        A modified copy of the this object
      • getName

        default java.lang.String getName()
        Returns the name of this group of radio buttons. All child radio buttons shared the same name (ICheckboxBase.getName()).

        Default: automatically generated a unique name

        Don't use this method if your application is purely based on ZK's event-driven model.

      • withName

        IRadiogroup withName​(java.lang.String name)
        Returns a copy of this immutable component with the specified name.

        Sets the name of this group of radio buttons. All child radio buttons shared the same name (ICheckboxBase.getName()).

        Don't use this method if your application is purely based on ZK's event-driven model.

        Parameters:
        name - The unique name to identify this component

        Default: no null.

        Returns:
        A modified copy of the this object
      • of

        static <I extends IAnyGroupIRadiogroup<I> of​(java.lang.Iterable<? extends I> children)
        Returns the instance with the given any group children.
        Parameters:
        children - The children belong to any group
        See Also:
        IAnyGroup
      • of

        static <I extends IAnyGroupIRadiogroup<I> of​(I... children)
        Returns the instance with the given any group children.
        Parameters:
        children - The children belong to any group
        See Also:
        IAnyGroup
      • ofId

        static <I extends IAnyGroupIRadiogroup<I> ofId​(java.lang.String id)
        Returns the instance with the given id.
        Parameters:
        id - The id to identify this component