Interface IMenuitem
-
- All Superinterfaces:
IChildrenOfInputgroup<IMenuitem>
,IChildrenOfMenupopup<IMenuitem>
,IComponent<IMenuitem>
,IDisable<IMenuitem>
,IHtmlBasedComponent<IMenuitem>
,ILabelElement<IMenuitem>
,ILabelImageElement<IMenuitem>
,IXulElement<IMenuitem>
public interface IMenuitem extends ILabelImageElement<IMenuitem>, IDisable<IMenuitem>, IChildrenOfMenupopup<IMenuitem>
ImmutableMenuitem
componentA 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 Classes Modifier and Type Interface Description static class
IMenuitem.Builder
Builds instances of typeIMenuitem
.static class
IMenuitem.Updater
Builds an updater of typeIMenuitem
forUiAgent.smartUpdate(Locator, SmartUpdater)
.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.lang.String
getAutodisable()
Returns a list of component IDs that shall be disabled when the user clicks this menuitem.java.lang.String
getHref()
Returns the href that the browser shall jump to, if a user clicks this button.java.lang.String
getTarget()
Returns the target frame or window.java.lang.String
getUpload()
Returns non-null if this component is used for file upload, or null otherwise.default java.lang.String
getWidgetClass()
Returns the client widget class.default boolean
isAutocheck()
Returns whether the menuitem check mark will update each time the menu item is selected.default boolean
isChecked()
Returns whether it is checked.default boolean
isCheckmark()
Returns whether the check mark shall be displayed in front of each item.static IMenuitem
of(java.lang.String label)
Returns the instance with the given label.static IMenuitem
of(java.lang.String label, java.lang.String image)
Returns the instance with the given label and image.static IMenuitem
ofId(java.lang.String id)
Returns the instance with the given id.static IMenuitem
ofImage(java.lang.String image)
Returns the instance with the given image.IMenuitem
withAutocheck(boolean autocheck)
Returns a copy ofthis
immutable component with the specifiedautocheck
.IMenuitem
withAutodisable(java.lang.String autodisable)
Returns a copy ofthis
immutable component with the specifiedautodisable
.IMenuitem
withChecked(boolean checked)
Returns a copy ofthis
immutable component with the specifiedchecked
.IMenuitem
withCheckmark(boolean checkmark)
Returns a copy ofthis
immutable component with the specifiedcheckmark
.IMenuitem
withHref(java.lang.String href)
Returns a copy ofthis
immutable component with the specifiedhref
.IMenuitem
withTarget(java.lang.String target)
Returns a copy ofthis
immutable component with the specifiedtarget
.IMenuitem
withUpload(java.lang.String upload)
Returns a copy ofthis
immutable 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, withWidgetOverrides
-
Methods inherited from interface org.zkoss.stateless.sul.IDisable
isDisabled, withDisabled
-
Methods inherited from interface org.zkoss.stateless.sul.IHtmlBasedComponent
getClientAction, getDraggable, getDroppable, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getStyle, getTabindex, getTooltiptext, getTop, getVflex, getWidth, getZclass, getZIndex, isFocus, withClientAction, withDraggable, withDroppable, withFocus, withHeight, withHflex, withLeft, withRenderdefer, withSclass, withStyle, withTabindex, withTabindex, withTooltiptext, withTop, withVflex, withWidth, withZclass, withZIndex
-
Methods inherited from interface org.zkoss.stateless.sul.ILabelElement
getLabel, withLabel
-
Methods inherited from interface org.zkoss.stateless.sul.ILabelImageElement
getHoverImage, getIconSclass, getIconSclasses, getIconTooltip, getIconTooltips, getImage, isPreloadImage, withHoverImage, withIconSclass, withIconSclasses, withIconTooltip, withIconTooltips, withImage, withPreloadImage
-
Methods inherited from interface org.zkoss.stateless.sul.IXulElement
getContext, getCtrlKeys, getPopup, getTooltip, withContext, withCtrlKeys, withPopup, withTooltip
-
-
-
-
Field Detail
-
DEFAULT
static final IMenuitem DEFAULT
Constant for default attributes of this immutable component.
-
-
Method Detail
-
getWidgetClass
default java.lang.String getWidgetClass()
Returns the client widget class.Default:
"zul.menu.Menuitem"
- Specified by:
getWidgetClass
in interfaceIComponent<IMenuitem>
-
getAutodisable
@Nullable java.lang.String getAutodisable()
Returns a list of component IDs that shall be disabled when the user clicks this menuitem.Default:
null
-
withAutodisable
IMenuitem withAutodisable(@Nullable java.lang.String autodisable)
Returns a copy ofthis
immutable 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
this
object
-
getHref
@Nullable java.lang.String 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
IMenuitem withHref(@Nullable java.lang.String href)
Returns a copy ofthis
immutable 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
this
object
-
getTarget
@Nullable java.lang.String 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
IMenuitem withTarget(@Nullable java.lang.String target)
Returns a copy ofthis
immutable 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
this
object
-
getUpload
@Nullable java.lang.String 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
IMenuitem withUpload(@Nullable java.lang.String upload)
Returns a copy ofthis
immutable 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
FileData
is 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
false
or the customized handler (likefoo.Upload
) are not specified, the option oftrue
is 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
this
object
- 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
IMenuitem withCheckmark(boolean checkmark)
Returns a copy ofthis
immutable 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
this
object
-
isChecked
default boolean isChecked()
Returns whether it is checked.Default:
false
.
-
withChecked
IMenuitem withChecked(boolean checked)
Returns a copy ofthis
immutable 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
this
object
-
isAutocheck
default boolean isAutocheck()
Returns whether the menuitem check mark will update each time the menu item is selected.Default:
false
.
-
withAutocheck
IMenuitem withAutocheck(boolean autocheck)
Returns a copy ofthis
immutable 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
this
object
-
of
static IMenuitem of(java.lang.String label)
Returns the instance with the given label.- Parameters:
label
- The label that the component
-
of
static IMenuitem of(java.lang.String label, java.lang.String image)
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
static IMenuitem ofImage(java.lang.String image)
Returns the instance with the given image.- Parameters:
image
- The image that the menuitem holds.
-
ofId
static IMenuitem ofId(java.lang.String id)
Returns the instance with the given id.- Parameters:
id
- The id to identify this component
-
-