Interface IButtonBase<I extends IButtonBase>
- All Superinterfaces:
IChildrenOfInputgroup<I>,IComponent<I>,IHtmlBasedComponent<I>,ILabelElement<I>,ILabelImageElement<I>,IXulElement<I>
- All Known Subinterfaces:
IButton,ICombobutton,IFileupload,IToolbarbutton
Button base component- Author:
- katherine
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumSpecifies the direction to layout image withwithDir(Direction)static enumSpecifies the orient withwithOrient(Orient)static enumSpecifies the type withwithType(Type) -
Method Summary
Modifier and TypeMethodDescriptiondefault voiddefault StringReturns a list of component IDs that shall be disabled when the user clicks this button.default StringgetDir()Returns the direction.default StringgetHref()Returns the href that the browser shall jump to, if a user clicks this button.default StringReturns the orient.default StringReturns the target frame or window.default StringgetType()Returns the button type.default StringReturns non-null if this component is used for file upload, or null otherwise.default booleanReturns whether it is disabled.withAutodisable(String autodisable) Returns a copy ofthisimmutable component with the specifiedautodisable.Returns a copy ofthisimmutable component with the specifieddir.default IReturns a copy ofthisimmutable component with the specifieddir.withDisabled(boolean disabled) Returns a copy ofthisimmutable component with the specifieddisabled.Returns a copy ofthisimmutable component with the specifiedhref.withOrient(String orient) Returns a copy ofthisimmutable component with the specifiedorient.default IwithOrient(IButtonBase.Orient orient) Returns a copy ofthisimmutable component with the specifiedorient.withTarget(String target) Returns a copy ofthisimmutable component with the specifiedtarget.Returns a copy ofthisimmutable component with the specifiedorient.default IwithType(IButtonBase.Type type) Returns a copy ofthisimmutable component with the specifiedorient.withUpload(String upload) Returns a copy ofthisimmutable component with the specifiedupload.Methods inherited from interface org.zkoss.stateless.sul.IComponent
getAction, getActions, getClientAttributes, getId, getMold, getWidgetClass, 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.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.ILabelElement
getLabel, withLabelMethods inherited from interface org.zkoss.stateless.sul.ILabelImageElement
getHoverImage, getIconSclass, getIconSclasses, getIconTooltip, getIconTooltips, getImage, isPreloadImage, withHoverImage, withIconSclass, withIconSclasses, withIconTooltip, withIconTooltips, withImage, withPreloadImageMethods inherited from interface org.zkoss.stateless.sul.IXulElement
getContext, getCtrlKeys, getPopup, getTooltip, withContext, withCtrlKeys, withPopup, withTooltip
-
Method Details
-
checkOrient
@Check default void checkOrient() -
getDir
Returns the direction.Default:
"normal". -
withDir
Returns a copy ofthisimmutable component with the specifieddir.Sets the direction to layout image.
- Parameters:
dir- The direction to layout image, either"normal"or"reverse"Default:
"normal".- Returns:
- A modified copy of the
thisobject
-
withDir
Returns a copy ofthisimmutable component with the specifieddir.Sets the direction to layout image.
- Parameters:
dir- The direction to layout image, either"normal"or"reverse"Default:
"normal".- Returns:
- A modified copy of the
thisobject
-
getOrient
Returns the orient.Default:
"horizontal". -
withOrient
Returns a copy ofthisimmutable component with the specifiedorient.Sets the orient to layout image.
- Parameters:
orient- the orient to layout image., 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 to layout image.
- Parameters:
orient- the orient to layout image., either"horizontal"or"vertical"Default:
"horizontal".- Returns:
- A modified copy of the
thisobject
-
getType
Returns the button type.Default:
"button". -
withType
Returns a copy ofthisimmutable component with the specifiedorient.Sets the button type. It is meaningful only if it is used with a HTML form. Refer to HTML Button Type for details.
- Parameters:
type- Either"button","submit"or"reset".Default:
"button".- Returns:
- A modified copy of the
thisobject
-
withType
Returns a copy ofthisimmutable component with the specifiedorient.Sets the button type. It is meaningful only if it is used with a HTML form. Refer to HTML Button Type for details.
- Parameters:
type- Either"button","submit"or"reset".Default:
"button".- Returns:
- A modified copy of the
thisobject
-
isDisabled
default boolean isDisabled()Returns whether it is disabled.Default:
false. -
withDisabled
Returns a copy ofthisimmutable component with the specifieddisabled.Sets whether it is disabled.
- Parameters:
disabled- Whether it is disabled.Default:
false.- Returns:
- A modified copy of the
thisobject
-
getAutodisable
Returns a list of component IDs that shall be disabled when the user clicks this button. -
withAutodisable
Returns a copy ofthisimmutable component with the specifiedautodisable.Sets a list of component IDs that shall be disabled when the user clicks this button.
To represent the button itself, the developer can specify
self. For example,.withAutodisable("self,cancel");is the same asIButton.ofId("ok").withAutodisable("ok,cancel");that will disable both the ok and cancel buttons when a user clicks it.The button being disabled will be enabled automatically once the client receives a response from the server. In other words, the server doesn't notice if a button is disabled with this method.
However, if you prefer to enable them later manually, you can prefix with '+'. For example,
IButton.ofId("ok").withAutodisable("+self,+cancel");Then, you have to enable them manually such as
if (something_happened){ uiAgent.smartUpdate(Locator.ofId("ok"), new IButton.Updater().disabled(false)); uiAgent.smartUpdate(Locator.ofId("cancel"), new IButton.Updater().disabled(false));- Parameters:
autodisable- Whether it is auto-disable.Default:
null.- Returns:
- A modified copy of the
thisobject
-
getTarget
Returns the target frame or window.Note: it is useful only if href (
withHref(java.lang.String)) is specified (i.e., use the onClick listener).Default:
null. -
withTarget
Returns a copy ofthisimmutable component with the specifiedtarget.Sets the target frame or window
- Parameters:
target- The name of the frame or window to hyperlink.Default:
null.- Returns:
- A modified copy of the
thisobject
-
getUpload
Returns non-null if this component is used for file upload, or null otherwise. Refer towithUpload(java.lang.String)for more details.Default:
null -
withUpload
Returns a copy ofthisimmutable component with the specifiedupload.Sets the JavaScript class at the client to handle the upload if this component is used for file upload.
For example, the following example declares a button for file upload:
IButton.of("Upload").withUpload("true").withAction(onUpload(this::doHandle));As shown above, after the file is uploaded, an instance of
FileDatais sent this handler.If you want to customize the handling of the file upload at the client, you can specify a JavaScript class when calling this method:
withUpload("foo.Upload");Another options for the upload can be specified as follows:
.withUpload("true,maxsize=-1,multiple=true,accept=audio/*|video/*|image/*,native");- maxsize: the maximal allowed upload size of the component, in kilobytes, or
a negative value if no limit, if the maxsize is not specified, it will use
Configuration.getMaxUploadSize() - native: treating the uploaded file(s) as binary, i.e., not to convert it to image, audio or text files.
- multiple: treating the file chooser allows multiple files to upload, the setting only works with HTML5 supported browsers.
- accept: specifies the types of files that the server accepts, the setting only works with HTML5 supported browsers.
- suppressedErrors: specifies the suppressed uploading errors, separated by
|(e.g. missing-required-component|illegal-upload) (since ZK 9.5.1).
Note: if the options of the
falseor the customized handler (likefoo.Upload) are not specified, the option oftrueis implicit by default.- Parameters:
upload- a JavaScript class to handle the file upload at the client, or "true" if the default class is used, or null or "false" to disable the file download (and then this button behaves like a normal button).Default:
null.- Returns:
- A modified copy of the
thisobject
- maxsize: the maximal allowed upload size of the component, in kilobytes, or
a negative value if no limit, if the maxsize is not specified, it will use
-
getHref
Returns the href that the browser shall jump to, if a user clicks this button.Default:
null. If null, the button has no function unless you specify the onClick event listener.If it is not null, the onClick event won't be sent.
-
withHref
Returns a copy ofthisimmutable component with the specifiedhref.Sets he href that the browser shall jump to, if a user clicks this button.
- Parameters:
href- The href that the browser shall jump to, if a user clicks this button.Default:
null.- Returns:
- A modified copy of the
thisobject
-