Interface IMenuitem
- All Superinterfaces:
IChildrenOfInputgroup<IMenuitem>,IChildrenOfMenupopup<IMenuitem>,IComponent<IMenuitem>,IDisable<IMenuitem>,IHtmlBasedComponent<IMenuitem>,ILabelElement<IMenuitem>,ILabelImageElement<IMenuitem>,IXulElement<IMenuitem>
Menuitem component
A single choice in a IMenupopup element.
It acts much like a button but it is rendered on a menu.
Support @Action
| Name | Action Type |
|---|---|
| onCheck | ActionData: CheckData
Denotes user has checked the item. |
| onUpload | ActionData: FileData
Denotes user has uploaded a file to the component. |
- Author:
- katherine
- See Also:
-
Menuitem
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classBuilds instances of typeIMenuitem.static classBuilds an updater of typeIMenuitemforUiAgent.smartUpdate(Locator, SmartUpdater). -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionReturns a list of component IDs that shall be disabled when the user clicks this menuitem.getHref()Returns the href that the browser shall jump to, if a user clicks this button.Returns the target frame or window.Returns non-null if this component is used for file upload, or null otherwise.default StringReturns the client widget class.default booleanReturns whether the menuitem check mark will update each time the menu item is selected.default booleanReturns whether it is checked.default booleanReturns whether the check mark shall be displayed in front of each item.static IMenuitemReturns the instance with the given label.static IMenuitemReturns the instance with the given label and image.static IMenuitemReturns the instance with the given id.static IMenuitemReturns the instance with the given image.withAutocheck(boolean autocheck) Returns a copy ofthisimmutable component with the specifiedautocheck.withAutodisable(String autodisable) Returns a copy ofthisimmutable component with the specifiedautodisable.withChecked(boolean checked) Returns a copy ofthisimmutable component with the specifiedchecked.withCheckmark(boolean checkmark) Returns a copy ofthisimmutable component with the specifiedcheckmark.Returns a copy ofthisimmutable component with the specifiedhref.withTarget(String target) Returns a copy ofthisimmutable component with the specifiedtarget.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, 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.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
-
Field Details
-
DEFAULT
Constant for default attributes of this immutable component.
-
-
Method Details
-
getWidgetClass
Returns the client widget class.Default:
"zul.menu.Menuitem"- Specified by:
getWidgetClassin interfaceIComponent<IMenuitem>
-
getAutodisable
Returns a list of component IDs that shall be disabled when the user clicks this menuitem.Default:
null -
withAutodisable
Returns a copy ofthisimmutable component with the specifiedautodisable.Sets a list of component IDs that shall be disabled when the user clicks this menuitem.
To represent the button itself, the developer can specify
self. For example,.withAutodisable("self,cancel");is the same asIMenuitem.ofId("ok").withAutodisable("ok,cancel");that will disable both the ok and cancel menuitems when a user clicks it.The menuitem 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 menuitem is disabled with this method.
However, if you prefer to enable them later manually, you can prefix with '+'. For example,
IMenuitem.ofId("ok").withAutodisable("+self,+cancel");Then, you have to enable them manually such as
if (something_happened){ uiAgent.smartUpdate(Locator.ofId("ok"), new IMenuitem.Updater().disabled(false)); uiAgent.smartUpdate(Locator.ofId("cancel"), new IMenuitem.Updater().disabled(false));- Parameters:
autodisable- Whether it is auto-disable.Default:
null.- Returns:
- A modified copy of the
thisobject
-
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 menuitem.
- Parameters:
href- The href that the browser shall jump to, if a user clicks this menuitem.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
-
isCheckmark
default boolean isCheckmark()Returns whether the check mark shall be displayed in front of each item.Default:
false. -
withCheckmark
Returns a copy ofthisimmutable component with the specifiedcheckmark.Sets whether the check mark shall be displayed in front of each item.
Note: the checkbox can be checked only if
isAutocheck()is true- Parameters:
checkmark- Whether the check mark shall be displayed in front of each itemDefault:
false.- Returns:
- A modified copy of the
thisobject
-
isChecked
default boolean isChecked()Returns whether it is checked.Default:
false. -
withChecked
Returns a copy ofthisimmutable component with the specifiedchecked.Sets whether it is checked.
Note: the checkbox can be checked only if
isAutocheck()is true- Parameters:
checked- Whether it is checked.Default:
false.- Returns:
- A modified copy of the
thisobject
-
isAutocheck
default boolean isAutocheck()Returns whether the menuitem check mark will update each time the menu item is selected.Default:
false. -
withAutocheck
Returns a copy ofthisimmutable component with the specifiedautocheck.Sets whether the menuitem check mark will update each time the menu item is selected.
- Parameters:
autocheck- Whether the menuitem check mark will update each time the menu item is selected.Default:
false.- Returns:
- A modified copy of the
thisobject
-
of
Returns the instance with the given label.- Parameters:
label- The label that the component
-
of
Returns the instance with the given label and image.- Parameters:
label- The label that the menuitem holds.image- The image that the menuitem holds.
-
ofImage
Returns the instance with the given image.- Parameters:
image- The image that the menuitem holds.
-
ofId
Returns the instance with the given id.- Parameters:
id- The id to identify this component
-