Interface IComponent<R extends IComponent>
-
- All Known Subinterfaces:
IA<I>,IAbsolutechildren<I>,IAbsolutelayout,IAnchornav<I>,IAnyGroup<I>,IArea,IAudio,IAuxhead,IAuxheader<I>,IBandbox,IBandpopup<I>,IBarcode,IBarcodescanner,IBiglistbox,IBorderlayout,IButton,IButtonBase<I>,ICalendar,ICamera,ICaption<I>,ICardlayout<I>,ICascader,ICell<I>,ICenter<I>,ICheckbox,ICheckboxBase<I>,IChildrenOfInputgroup<I>,IChildrenOfMenupopup<I>,IChildrenOfNavbar<I>,IChildrenOfPanel<I>,IChildrenOfTab<I>,IChosenbox,ICoachmark<I>,IColorbox,IColumn<I>,IColumnchildren<I>,IColumnlayout,IColumns,ICombobox,ICombobutton,IComboitem,ICropper,IDatebox,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>
public interface IComponent<R extends IComponent>ImmutableComponentinterface.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
For example,actionor multipleactionson 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.
As you can see, the@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); }@ActionVariable()annotation declared on thedoSubmit()method handler is a way to receive the client widget state at server, in this case, themsgvalue is the value of theITextbox, which the user types if any.Note: It's convenient to use
doSubmit(String msg)directly if the Javac compiler with-parametersto generate metadata for reflection on method parameters.- Author:
- jumperchen
- See Also:
ActionVariable,Action
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description ActionHandlergetAction()Returns theActionHandlerif any.java.util.List<ActionHandler>getActions()Returns all theActionHandlers if any.java.util.Map<java.lang.String,java.lang.String>getClientAttributes()Returns the client DOM attributes.default java.lang.StringgetId()Returns the ID.default java.lang.StringgetMold()Returns the mold used to render this component.java.lang.StringgetWidgetClass()Returns the client widget class which belongs to this component.java.util.Map<java.lang.String,java.lang.String>getWidgetListeners()Returns the client widget listeners.java.util.Map<java.lang.String,java.lang.String>getWidgetOverrides()Returns the mapping of the script and the function definition to override widget's methods and attributes, or null.default booleanisVisible()Returns whether this component is visible at client.RwithAction(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>
RwithAction(ActionHandler2<A,B> action)Returns a copy ofthisimmutable component with the specifiedaction.default <A,B,C>
RwithAction(ActionHandler3<A,B,C> action)Returns a copy ofthisimmutable component with the specifiedaction.default <A,B,C,D>
RwithAction(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.RwithActions(java.lang.Iterable<? extends ActionHandler> actions)Returns a copy ofthisimmutable component with the specifiedactions.RwithActions(ActionHandler... actions)Returns a copy ofthisimmutable component with the specifiedactions.default RwithClientAttribute(java.lang.String name, java.lang.String value)Returns a copy ofthisimmutable component with the specifiednameandvalue.RwithClientAttributes(java.util.Map<java.lang.String,? extends java.lang.String> clientAttributes)Returns a copy ofthisimmutable component with the specifiedclientAttributes.RwithId(java.lang.String id)Returns a copy ofthisimmutable component with the specifiedID.RwithMold(java.lang.String mold)Returns a copy ofthisimmutable component with the specifiedmold.RwithVisible(boolean visible)Returns a copy ofthisimmutable component with the specifiedvisible.RwithWidgetClass(java.lang.String widgetClass)Returns a copy ofthisimmutable component with the specifiedwidgetClass.default RwithWidgetListener(java.lang.String eventName, java.lang.String script)Returns a copy ofthisimmutable component with the specifiedeventNameandscript.RwithWidgetListeners(java.util.Map<java.lang.String,? extends java.lang.String> widgetListeners)Returns a copy ofthisimmutable component with the specifiedwidgetListeners.default RwithWidgetOverride(java.lang.String name, java.lang.String script)Returns a copy ofthisimmutable component with the specifiednameandscript.RwithWidgetOverrides(java.util.Map<java.lang.String,? extends java.lang.String> widgetOverrides)Returns a copy ofthisimmutable component with the specifiedwidgetOverrides.
-
-
-
Method Detail
-
getId
default java.lang.String 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
R withId(java.lang.String id)
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
java.lang.String getWidgetClass()
Returns the client widget class which belongs to this component.
-
withWidgetClass
R withWidgetClass(java.lang.String widgetClass)
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
@Nullable ActionHandler getAction()
Returns theActionHandlerif any.Default:
null
-
getActions
@Nullable java.util.List<ActionHandler> getActions()
Returns all theActionHandlers if any.Default:
null
-
withActions
R withActions(@Nullable ActionHandler... actions)
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:
withAction(ActionHandler),withActions(Iterable)
-
withActions
R withActions(@Nullable java.lang.Iterable<? extends ActionHandler> actions)
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:
withActions(ActionHandler...)
-
isVisible
default boolean isVisible()
Returns whether this component is visible at client.Default:
true
-
withVisible
R withVisible(boolean visible)
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
default java.lang.String getMold()
Returns the mold used to render this component.Default:
"default"
-
withMold
R withMold(java.lang.String mold)
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
R withAction(@Nullable ActionHandler action)
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:
ActionHandler
-
withAction
default R withAction(@Nullable ActionHandler0 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:
ActionHandler0,withAction(ActionHandler)
-
withAction
default <A> R withAction(@Nullable ActionHandler1<A> 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:
ActionHandler1,withAction(ActionHandler)
-
withAction
default <A,B> R withAction(@Nullable ActionHandler2<A,B> 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:
ActionHandler2,withAction(ActionHandler)
-
withAction
default <A,B,C> R withAction(@Nullable ActionHandler3<A,B,C> 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:
ActionHandler3,withAction(ActionHandler)
-
withAction
default <A,B,C,D> R withAction(@Nullable ActionHandler4<A,B,C,D> 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:
ActionHandler4,withAction(ActionHandler)
-
withAction
default <A,B,C,D,E> R withAction(@Nullable ActionHandler5<A,B,C,D,E> 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:
ActionHandler5,withAction(ActionHandler)
-
withAction
default <A,B,C,D,E,F> R withAction(@Nullable ActionHandler6<A,B,C,D,E,F> 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:
ActionHandler6,withAction(ActionHandler)
-
withAction
default <A,B,C,D,E,F,G> R withAction(@Nullable ActionHandler7<A,B,C,D,E,F,G> 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:
ActionHandler7,withAction(ActionHandler)
-
withAction
default <A,B,C,D,E,F,G,H> R withAction(@Nullable ActionHandler8<A,B,C,D,E,F,G,H> 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:
ActionHandler8,withAction(ActionHandler)
-
withAction
default <A,B,C,D,E,F,G,H,I> R withAction(@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:
ActionHandler9,withAction(ActionHandler)
-
getWidgetListeners
@Nullable java.util.Map<java.lang.String,java.lang.String> getWidgetListeners()
Returns the client widget listeners.
-
withWidgetListeners
R withWidgetListeners(@Nullable java.util.Map<java.lang.String,? extends java.lang.String> widgetListeners)
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
default R withWidgetListener(java.lang.String eventName, java.lang.String script)
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
@Nullable java.util.Map<java.lang.String,java.lang.String> getWidgetOverrides()
Returns the mapping of the script and the function definition to override widget's methods and attributes, or null.
-
withWidgetOverrides
R withWidgetOverrides(@Nullable java.util.Map<java.lang.String,? extends java.lang.String> widgetOverrides)
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
default R withWidgetOverride(java.lang.String name, java.lang.String script)
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
@Nullable java.util.Map<java.lang.String,java.lang.String> getClientAttributes()
Returns the client DOM attributes.
-
withClientAttributes
R withClientAttributes(@Nullable java.util.Map<java.lang.String,? extends java.lang.String> clientAttributes)
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
default R withClientAttribute(java.lang.String name, java.lang.String value)
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
-
-