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>>
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
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classIRadiogroup.Builder<I extends IAnyGroup>Builds instances of typeIRadiogroup.static enumSpecifies the orient ofIRadiogroupcomponentstatic classBuilds an updater of typeIRadiogroupforUiAgent.smartUpdate(Locator, SmartUpdater). -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final IRadiogroup<IAnyGroup>Constant for default attributes of this immutable component. -
Method Summary
Modifier and TypeMethodDescriptiondefault StringgetName()Returns the name of this group of radio buttons.default StringReturns the orient.default StringReturns the client widget class.static <I extends IAnyGroup>
IRadiogroup<I>of(I... children) Returns the instance with the given any group children.static <I extends IAnyGroup>
IRadiogroup<I>Returns the instance with the given any group children.static <I extends IAnyGroup>
IRadiogroup<I>Returns the instance with the given id.Returns a copy ofthisimmutable component with the specifiedname.withOrient(String orient) Returns a copy ofthisimmutable component with the specifiedorient.default IRadiogroup<I>withOrient(IRadiogroup.Orient orient) Returns a copy ofthisimmutable component with the specifiedorient.Methods inherited from interface org.zkoss.stateless.sul.IChildable
getChildren, withChildren, withChildrenMethods inherited from interface org.zkoss.stateless.sul.IComponent
getAction, getActions, getClientAttributes, getId, getMold, getWidgetListeners, getWidgetOverrides, isVisible, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withActions, withActions, withClientAttribute, withClientAttributes, withId, withMold, withVisible, withWidgetClass, withWidgetListener, withWidgetListeners, withWidgetOverride, withWidgetOverridesMethods inherited from interface org.zkoss.stateless.sul.IDisable
isDisabled, withDisabledMethods inherited from interface org.zkoss.stateless.sul.IHtmlBasedComponent
getClientAction, getDraggable, getDroppable, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getSkeleton, getStyle, getTabindex, getTooltiptext, getTop, getVflex, getWidth, getZclass, getZIndex, isFocus, withClientAction, withDraggable, withDroppable, withFocus, withHeight, withHflex, withLeft, withRenderdefer, withSclass, withSkeleton, withStyle, withTabindex, withTabindex, withTooltiptext, withTop, withVflex, withWidth, withZclass, withZIndexMethods inherited from interface org.zkoss.stateless.sul.IXulElement
getContext, getCtrlKeys, getPopup, getTooltip, withContext, withCtrlKeys, withPopup, withTooltip
-
Field Details
-
DEFAULT
Constant for default attributes of this immutable component.
-
-
Method Details
-
getWidgetClass
Returns the client widget class.Default:
"zul.wgt.Radiogroup"- Specified by:
getWidgetClassin interfaceIComponent<I extends IAnyGroup>
-
getOrient
Returns the orient.Default:
"horizontal". -
withOrient
Returns a copy ofthisimmutable component with the specifiedorient.Sets the orient of component
- Parameters:
orient- Either"horizontal"or"vertical"Default:
"horizontal".- Returns:
- A modified copy of the
thisobject
-
withOrient
Returns a copy ofthisimmutable component with the specifiedorient.Sets the orient of component
- Parameters:
orient- TheorientDefault:
"horizontal".- Returns:
- A modified copy of the
thisobject
-
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
Returns a copy ofthisimmutable component with the specifiedname.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 componentDefault: no null.
- Returns:
- A modified copy of the
thisobject
-
of
Returns the instance with the given any group children.- Parameters:
children- The children belong to any group- See Also:
-
of
Returns the instance with the given any group children.- Parameters:
children- The children belong to any group- See Also:
-
ofId
Returns the instance with the given id.- Parameters:
id- The id to identify this component
-