Interface IComponent<R extends IComponent>
- All Known Subinterfaces:
IA<I>,IAbsolutechildren<I>,IAbsolutelayout,IAnchornav<I>,IAnyGroup<I>,IArea,IAudio,IAuxhead,IAuxheader<I>,IAvatar,IAvatargroup,IBadge<I>,IBandbox,IBandpopup<I>,IBarcode,IBarcodescanner,IBiglistbox,IBorderlayout,IBreadcrumb,IBreadcrumbitem,IButton,IButtonBase<I>,ICalendar,ICamera,ICaption<I>,ICardlayout<I>,ICarousel,ICarouselitem<I>,ICascader,ICell<I>,ICenter<I>,ICheckbox,ICheckboxBase<I>,IChildrenOfInputgroup<I>,IChildrenOfMenupopup<I>,IChildrenOfNavbar<I>,IChildrenOfPanel<I>,IChildrenOfTab<I>,IChip,IChosenbox,ICoachmark<I>,ICodeeditor,IColorbox,IColumn<I>,IColumnchildren<I>,IColumnlayout,IColumns,ICombobox,ICombobutton,IComboitem,IConfirmpopup,ICropper,IDatebox,IDaterangebox,IDateTimeFormatInputElement<I>,IDecimalbox,IDetail<I>,IDetailChild<I>,IDiv<I>,IDoublebox,IDoublespinner,IDrawer<I>,IDropupload,IEast<I>,IFileupload,IFisheye,IFisheyebar,IFoot,IFooter<I>,IFooterElement<I>,IFormatInputElement<I,,ValueTypeT> IFrozen<I>,IGoldenLayout,IGoldenPanel<I>,IGrid,IGridComposite<I>,IGroup<I>,IGroupbox<I>,IGroupChild<I>,IGroupfoot<I>,IGroupfootChild<I>,IHeaderElement<I>,IHeadersElement<I>,IHlayout<I>,IHtml,IHtmlBasedComponent<I>,IIframe,IImage,IImageBase<I>,IImagemap,IInputElement<I,,ValueTypeT> IInputgroup,IIntbox,ILabel,ILabelElement<I>,ILabelImageElement<I>,ILayout<I>,ILayoutRegion<I>,ILineitem<I>,ILinelayout,IListbox,IListboxComposite<I>,IListcell<I>,IListfoot,IListfooter<I>,IListgroup,IListgroupChild<I>,IListgroupfoot,IListgroupfootChild<I>,IListhead,IListheader<I>,IListitem,IListitemBase<I>,ILongbox,IMenu,IMenubar,IMenuitem,IMenupopup,IMenuseparator,IMeshComposite<I>,IMeshElement<I>,IMultislider,INav,INavbar,INavitem,INavseparator,INorth<I>,INumberInputElement<I,,ValueTypeT> IOrganigram,IOrgchildren,IOrgitem,IOrgitemComposite<I>,IOrgnode<I>,IPaging,IPanel,IPanelchildren<I>,IPdfviewer,IPopup<I>,IPopupBase<I>,IPortalchildren,IPortallayout,IProgressmeter,IRadio,IRadiogroup<I>,IRangeslider,IRangesliderBase<I>,IRating,IRow<I>,IRowBase<I>,IRowchildren<I>,IRowlayout,IRows,IScript,IScrollview<I>,ISearchbox,ISelectbox,ISeparator,ISeparatorBase<I>,ISignature,ISlider,ISliderbuttons,ISouth<I>,ISpace,ISpan<I>,ISpinner,ISplitlayout<I>,IStep,IStepbar,IStyle,ITab,ITabbox,ITabboxComposite<I>,ITablechildren<I>,ITablelayout,ITabpanel<I>,ITabpanels,ITabs,ITbeditor,ITextbox,ITextboxBase<I>,ITimebox,ITimepicker,ITimer,IToolbar<I>,IToolbarbutton,ITrack,ITree,ITreecell<I>,ITreechildren,ITreecol<I>,ITreecols,ITreeComposite<I>,ITreefoot,ITreefooter<I>,ITreeitem,ITreeitemComposite<I>,ITreerow,IVideo,IVlayout<I>,IWest<I>,IWindow<I>,IXulElement<I>
Component interface.
Provides a set of immutable APIs of a ZK component to create a same result
as ZK component to client side, and by hooking an action
or multiple actions on a client widget
triggers a user action to server to handle it in a stateless HTTP request protocol,
and then the developer can manipulate the client state at server by an action handler.
@RichletMapping("")
public IComponent index() {
return IVlayout.of(ITextbox.ofId("msg"),
IButton.of("Submit").withAction(this::doSubmit));
}
@Action(type = Events.ON_CLICK)
public void doSubmit(@ActionVariable(targetId="msg", field="value") String msg) {
Clients.alert("Hello " + msg);
}
As you can see, the @ActionVariable() annotation declared on the doSubmit()
method handler is a way to receive the client widget state at server,
in this case, the msg value is the value of the ITextbox,
which the user types if any.
Note: It's convenient to use doSubmit(String msg) directly if the Javac compiler
with -parameters to generate metadata for reflection on method parameters.
- Author:
- jumperchen
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionReturns theActionHandlerif any.Returns all theActionHandlers if any.Returns the client DOM attributes.default StringgetId()Returns the ID.default StringgetMold()Returns the mold used to render this component.Returns the client widget class which belongs to this component.Returns the client widget listeners.Returns the mapping of the script and the function definition to override widget's methods and attributes, or null.default booleanReturns whether this component is visible at client.withAction(ActionHandler action) Returns a copy ofthisimmutable component with the specifiedaction.default RwithAction(ActionHandler0 action) Returns a copy ofthisimmutable component with the specifiedaction.default <A> RwithAction(ActionHandler1<A> action) Returns a copy ofthisimmutable component with the specifiedaction.default <A,B> R withAction(ActionHandler2<A, B> action) Returns a copy ofthisimmutable component with the specifiedaction.default <A,B, C> R withAction(ActionHandler3<A, B, C> action) Returns a copy ofthisimmutable component with the specifiedaction.default <A,B, C, D> R withAction(ActionHandler4<A, B, C, D> action) Returns a copy ofthisimmutable component with the specifiedaction.default <A,B, C, D, E>
RwithAction(ActionHandler5<A, B, C, D, E> action) Returns a copy ofthisimmutable component with the specifiedaction.default <A,B, C, D, E, F>
RwithAction(ActionHandler6<A, B, C, D, E, F> action) Returns a copy ofthisimmutable component with the specifiedaction.default <A,B, C, D, E, F, G>
RwithAction(ActionHandler7<A, B, C, D, E, F, G> action) Returns a copy ofthisimmutable component with the specifiedaction.default <A,B, C, D, E, F, G, H>
RwithAction(ActionHandler8<A, B, C, D, E, F, G, H> action) Returns a copy ofthisimmutable component with the specifiedaction.default <A,B, C, D, E, F, G, H, I>
RwithAction(ActionHandler9<A, B, C, D, E, F, G, H, I> action) Returns a copy ofthisimmutable component with the specifiedaction.withActions(Iterable<? extends ActionHandler> actions) Returns a copy ofthisimmutable component with the specifiedactions.withActions(ActionHandler... actions) Returns a copy ofthisimmutable component with the specifiedactions.default RwithClientAttribute(String name, String value) Returns a copy ofthisimmutable component with the specifiednameandvalue.withClientAttributes(Map<String, ? extends String> clientAttributes) Returns a copy ofthisimmutable component with the specifiedclientAttributes.Returns a copy ofthisimmutable component with the specifiedID.Returns a copy ofthisimmutable component with the specifiedmold.withVisible(boolean visible) Returns a copy ofthisimmutable component with the specifiedvisible.withWidgetClass(String widgetClass) Returns a copy ofthisimmutable component with the specifiedwidgetClass.default RwithWidgetListener(String eventName, String script) Returns a copy ofthisimmutable component with the specifiedeventNameandscript.withWidgetListeners(Map<String, ? extends String> widgetListeners) Returns a copy ofthisimmutable component with the specifiedwidgetListeners.default RwithWidgetOverride(String name, String script) Returns a copy ofthisimmutable component with the specifiednameandscript.withWidgetOverrides(Map<String, ? extends String> widgetOverrides) Returns a copy ofthisimmutable component with the specifiedwidgetOverrides.
-
Method Details
-
getId
Returns the ID.Default:
""(an empty string; it means no ID at all).
Note: Unlike ZK Component, there is no ID Space in Stateless Component, so theIDshould be unique within a Desktop Scope, aka a browser page. -
withId
Returns a copy ofthisimmutable component with the specifiedID.Note: Unlike ZK Component, there is no ID Space in Stateless Component, so the
IDshould be unique within a Desktop Scope, aka a browser page.- Parameters:
id- The identifier. You could specify null or an empty string to remove ID.Default:
""(an empty string; it means no ID at all).- Returns:
- A modified copy of the
thisobject
-
getWidgetClass
String getWidgetClass()Returns the client widget class which belongs to this component. -
withWidgetClass
Returns a copy ofthisimmutable component with the specifiedwidgetClass.- Parameters:
widgetClass- The client widget class (a.k.a., the widget type). The widget class is a JavaScript class, including the package name.
For example,"zul.wnd.Window".- Returns:
- A modified copy of the
thisobject
-
getAction
Returns theActionHandlerif any.Default:
null -
getActions
Returns all theActionHandlers if any.Default:
null -
withActions
Returns a copy ofthisimmutable component with the specifiedactions.To register multiple action handler, the action type can be one of the
typesor the types inorg.zkoss.stateless.action.ActionTypeEx
For example,
@RichletMapping("") public IComponent index() { return ICheckbox.ofId("myCheckbox").withActions(ActionType.onCheck(this::doMyCheck), ActionType.onRightClick(this::doMyRightClick), ...); } public void doMyCheck() { } public void doMyRightClick() { }Note: The
withActions()won't overwrite the one returned fromgetAction(), which is convenient for registering a single action.- Parameters:
actions- The multiple actions to register with differentActionTypes- Returns:
- A modified copy of
thisobject - See Also:
-
withActions
Returns a copy ofthisimmutable component with the specifiedactions.- Parameters:
actions- The multiple actions to register with differentActionTypes- Returns:
- A modified copy of
thisobject - See Also:
-
isVisible
default boolean isVisible()Returns whether this component is visible at client.Default:
true -
withVisible
Returns a copy ofthisimmutable component with the specifiedvisible.- Parameters:
visible- Sets whetherthiscomponent is visible at client.Default:
true- Returns:
- A modified copy of
thisobject
-
getMold
Returns the mold used to render this component.Default:
"default" -
withMold
Returns a copy ofthisimmutable component with the specifiedmold.- Parameters:
mold- Sets the mold to renderthiscomponent.Default:
, if"default"nullor an empty string"", the"default"value is assumed.- Returns:
- A modified copy of
thisobject
-
withAction
Returns a copy ofthisimmutable component with the specifiedaction.To register a single action handler, the action type can be one of the
typesor the types inorg.zkoss.stateless.action.ActionTypeEx
For example, (with a specificAcitonType.onClick())
Or with@RichletMapping("") public IComponent index() { return ICheckbox.ofId("myCheckbox").withAction(ActionType.onClick(this::doMyClick)); } public void doMyClick() { }@Actionannotation on a method, for example,
As you can see above, both ways are the same result to register a single action handler to an immutable component, but the priority of an action type of the first one with@RichletMapping("") public IComponent index() { return ICheckbox.ofId("myCheckbox").withAction(this::doMyClick); } @Action(type = Events.ON_CLICK) public void doMyClick() { }ActionType.onClick()is higher than the second one with@Action()annotation, in other words, the action type can be overwritten by anytypesor the types inorg.zkoss.stateless.action.ActionTypeExwith the syntaxwithAction(ActionType.onClick()). It's convenient to share one method handler for multiple action types.Note: The
withAction()won't overwrite any one returned fromgetActions(), which is convenient for registering multiple actions.- Parameters:
action- A new action ofActionTypeto register (can benull)- Returns:
- A modified copy of the
thisobject - See Also:
-
withAction
Returns a copy ofthisimmutable component with the specifiedaction.- Parameters:
action- A new action ofActionTypeto register (can benull)- Returns:
- A modified copy of the
thisobject - See Also:
-
withAction
Returns a copy ofthisimmutable component with the specifiedaction.- Parameters:
action- A new action ofActionTypeto register (can benull)- Returns:
- A modified copy of the
thisobject - See Also:
-
withAction
Returns a copy ofthisimmutable component with the specifiedaction.- Parameters:
action- A new action ofActionTypeto register (can benull)- Returns:
- A modified copy of the
thisobject - See Also:
-
withAction
Returns a copy ofthisimmutable component with the specifiedaction.- Parameters:
action- A new action ofActionTypeto register (can benull)- Returns:
- A modified copy of the
thisobject - See Also:
-
withAction
Returns a copy ofthisimmutable component with the specifiedaction.- Parameters:
action- A new action ofActionTypeto register (can benull)- Returns:
- A modified copy of the
thisobject - See Also:
-
withAction
Returns a copy ofthisimmutable component with the specifiedaction.- Parameters:
action- A new action ofActionTypeto register (can benull)- Returns:
- A modified copy of the
thisobject - See Also:
-
withAction
Returns a copy ofthisimmutable component with the specifiedaction.- Parameters:
action- A new action ofActionTypeto register (can benull)- Returns:
- A modified copy of the
thisobject - See Also:
-
withAction
Returns a copy ofthisimmutable component with the specifiedaction.- Parameters:
action- A new action ofActionTypeto register (can benull)- Returns:
- A modified copy of the
thisobject - See Also:
-
withAction
Returns a copy ofthisimmutable component with the specifiedaction.- Parameters:
action- A new action ofActionTypeto register (can benull)- Returns:
- A modified copy of the
thisobject - See Also:
-
withAction
default <A,B, R withActionC, D, E, F, G, H, I> (@Nullable ActionHandler9<A, B, C, D, E, F, G, H, I> action) Returns a copy ofthisimmutable component with the specifiedaction.- Parameters:
action- A new action ofActionTypeto register (can benull)- Returns:
- A modified copy of the
thisobject - See Also:
-
getWidgetListeners
Returns the client widget listeners. -
withWidgetListeners
Returns a copy ofthisimmutable component with the specifiedwidgetListeners.Sets or removes an event listener of the peer widget. If there is an event listener associated with the same event, the previous one will be replaced.
- Parameters:
widgetListeners- The client widget listeners- Returns:
- A modified copy of the
thisobject
-
withWidgetListener
Returns a copy ofthisimmutable component with the specifiedeventNameandscript.Sets or removes an event listener of the peer widget. If there is an event listener associated with the same event, the previous one will be replaced.
- Parameters:
eventName- The event name, such asonClickscript- The script to handle the event. If null, the event handler is removed.- Returns:
- A modified copy of the
thisobject
-
getWidgetOverrides
Returns the mapping of the script and the function definition to override widget's methods and attributes, or null. -
withWidgetOverrides
Returns a copy ofthisimmutable component with the specifiedwidgetOverrides.Sets or removes a method or an attribute of the peer widget (at the client). If there is a method or an attribute associated with the same name, the previous one will be replaced.
If there is no previous method or attribute, the method/attribute will be assigned directly.
- Parameters:
widgetOverrides- The client widget overrides for methods and attributes- Returns:
- A modified copy of the
thisobject
-
withWidgetOverride
Returns a copy ofthisimmutable component with the specifiednameandscript.Sets or removes a method or an attribute of the peer widget (at the client). If there is a method or a attribute associated with the same name, the previous one will be replaced.
- Parameters:
name- The attribute name to override, such assetValueandmiles.script- the method definition, such asfunction (arg) {...}, or a value, such as123andnew Date(). If not null, this method will be added to the peer widget. If there was a method with the same name, it will be renamed to$nameso can you call it back.
If null, the previous method, if any, will be restored..withWidgetOverride("setValue", "function (value) {" + "this.$setValue(value); //old method" + "}");- Returns:
- A modified copy of the
thisobject
-
getClientAttributes
Returns the client DOM attributes. -
withClientAttributes
Returns a copy ofthisimmutable component with the specifiedclientAttributes.Sets or removes a DOM attribute of the peer widget (at the client). ZK pass the attributes directly to the DOM attribute generated at the client.
- Parameters:
clientAttributes- The client DOM attributes- Returns:
- A modified copy of the
thisobject
-
withClientAttribute
Returns a copy ofthisimmutable component with the specifiednameandvalue.Sets or removes a DOM attribute of the peer widget (at the client). ZK pass the attributes directly to the DOM attribute generated at the client.
- Parameters:
name- the attribute name to generate to the DOM element, such asonload.value- the value of the attribute. It could be anything depending on the attribute. If null, the attribute will be removed. Make sure to specify an empty string if you want an attribute with an empty value.- Returns:
- A modified copy of the
thisobject
-