public class WMenuItem extends AbstractContainer implements Disableable, AjaxTrigger, MenuItemSelectable, DialogOpenTrigger, AccessKeyable
WMenu
or as an item within
a WSubMenu
or WMenuItemGroup
.Modifier and Type | Class and Description |
---|---|
static class |
WMenuItem.MenuItemModel
Holds the extrinsic state information of a WMenuItem.
|
AbstractWComponent.WComponentRef
DEFAULT_APPLICATION_ID, DEFAULT_INTERNAL_ID, DEFAULT_NO_ID, ID_CONTEXT_SEPERATOR, ID_FRAMEWORK_ASSIGNED_SEPERATOR, ID_VALIDATION_PATTERN
Constructor and Description |
---|
WMenuItem(String text)
Creates a new WMenuItem with the specified text.
|
WMenuItem(String text,
Action action)
Creates a WMenuItem with the given label and action.
|
WMenuItem(String text,
char accessKey)
Creates a new WMenuItem with the specified text and accessKey.
|
WMenuItem(String text,
char accessKey,
Action action)
Creates a new WMenuItem with the specified text, accessKey and action.
|
WMenuItem(String text,
String url)
Creates a WMenuItem with the given text and url.
|
WMenuItem(WDecoratedLabel label)
Creates a WMenuItem with the given label.
|
WMenuItem(WDecoratedLabel label,
Action action)
Creates a WMenuItem with the given label and action.
|
WMenuItem(WDecoratedLabel label,
String url)
Creates a WMenuItem with the given label and url.
|
Modifier and Type | Method and Description |
---|---|
char |
getAccessKey() |
Action |
getAction() |
String |
getActionCommand()
Retrieves this menu item's action command.
|
Serializable |
getActionObject()
Retrieves this menu item's action object.
|
protected WMenuItem.MenuItemModel |
getComponentModel()
Returns the effective component model for this component.
|
WDecoratedLabel |
getDecoratedLabel() |
String |
getMessage() |
protected WMenuItem.MenuItemModel |
getOrCreateComponentModel()
Retrieves the model for this component so that it can be modified.
|
Boolean |
getSelectability()
Symmetric accessor which should not generally be used.
|
String |
getTargetWindow()
Retrieves the target window name.
|
String |
getText()
Retrieves the menu item text.
|
String |
getUrl()
Retrieves the menu item's URL.
|
void |
handleRequest(Request request)
Override handleRequest in order to perform processing for this component.
|
boolean |
isCancel() |
boolean |
isDisabled()
Indicates whether this menu item is disabled in the given context.
|
protected boolean |
isMenuPresent(Request request)
Determine if this WMenuItem's parent WMenu is on the Request.
|
Boolean |
isSelectable()
Deprecated.
Use
getSelectability() instead. |
boolean |
isSelectAllowed() |
boolean |
isSelected() |
boolean |
isSubmit()
Indicates whether the form should be submitted when the menu item is selected.
|
boolean |
isTopLevelItem() |
protected WMenuItem.MenuItemModel |
newComponentModel()
Creates a new component model.
|
void |
setAccessKey(char accessKey)
Set the access key on the component.
|
void |
setAction(Action action)
Sets the action to execute when the menu item is invoked.
|
void |
setActionCommand(String actionCommand)
Sets this menu item's action command.
|
void |
setActionObject(Serializable actionObject)
Sets this menu item's action object.
|
void |
setCancel(boolean cancel) |
void |
setDisabled(boolean disabled)
Sets whether this menu item is disabled.
|
void |
setMessage(String message,
Serializable... args)
Sets the confirmation message that is to be displayed to the user for this menu item.
|
void |
setSelectability(Boolean selectability) |
void |
setSelectable(Boolean selectable)
Deprecated.
Use
setSelectability(java.lang.Boolean) instead. |
void |
setTargetWindow(String targetWindow)
Sets this menu item's target window name.
|
void |
setText(String text)
Sets the text of the menu item.
|
void |
setUrl(String url)
Sets the URL to navigate to when the menu item is invoked.
|
String |
toString()
Creates a String representation of this component; usually for debugging purposes.
|
getChildAt, getChildCount, getChildren, getIndexOfChild
addHtmlClass, addHtmlClass, addNotify, afterPaint, assertAddSupported, beforePaint, createErrorDiagnostic, createErrorDiagnostic, forward, getAccessibleText, getAttribute, getBaseUrl, getDefaultModel, getEnvironment, getHeaders, getHtmlClass, getHtmlClasses, getId, getIdName, getInternalId, getLabel, getName, getParent, getScratchMap, getTabIndex, getTag, getTemplate, getTemplateMarkUp, getToolTip, hasNoComponentModel, hasTabIndex, initialiseComponentModel, invokeLater, invokeLaters, isDebugStructure, isDefaultState, isFlagSet, isHidden, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, isVisible, paint, paintComponent, preparePaint, preparePaintComponent, removeAttribute, removeComponentModel, removeHtmlClass, removeHtmlClass, removeNotify, replaceWComponent, reset, serviceRequest, setAccessibleText, setAttribute, setEnvironment, setFlag, setFocussed, setHidden, setHtmlClass, setHtmlClass, setIdName, setInitialised, setLocked, setTag, setToolTip, setTrackingEnabled, setValidate, setVisible, showErrorIndicators, showErrorIndicatorsForComponent, showWarningIndicators, showWarningIndicatorsForComponent, tidyUpUIContext, tidyUpUIContextForTree, validate, validateComponent, writeReplace
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addHtmlClass, addHtmlClass, forward, getAccessibleText, getAttribute, getBaseUrl, getEnvironment, getHeaders, getHtmlClass, getHtmlClasses, getId, getIdName, getInternalId, getLabel, getName, getParent, getTabIndex, getTag, getToolTip, hasTabIndex, invokeLater, isDefaultState, isHidden, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, isVisible, paint, preparePaint, removeAttribute, removeHtmlClass, removeHtmlClass, reset, serviceRequest, setAccessibleText, setAttribute, setEnvironment, setFocussed, setHtmlClass, setHtmlClass, setIdName, setInitialised, setLocked, setTag, setToolTip, setTrackingEnabled, setValidate, setVisible, showErrorIndicators, showWarningIndicators, tidyUpUIContextForTree, validate
getAccessKeyAsString
public WMenuItem(WDecoratedLabel label)
label
- the menu item label.public WMenuItem(WDecoratedLabel label, String url)
label
- the menu item label.url
- the URL to navigate to when the menu item is invoked.public WMenuItem(WDecoratedLabel label, Action action)
label
- the menu item label.action
- the action to execute when the menu item is invoked.public WMenuItem(String text, String url)
text
- the menu item text.url
- the URL to navigate to when the menu item is invoked.public WMenuItem(String text, Action action)
text
- the menu item text.action
- the action to execute when the menu item is invoked.public WMenuItem(String text)
text
- the menu item's text.public WMenuItem(String text, char accessKey)
text
- the menu item's text.accessKey
- the menu item's access key.public WDecoratedLabel getDecoratedLabel()
public Action getAction()
public void setAction(Action action)
action
- the menu item's action.public String getUrl()
public void setUrl(String url)
url
- the url to set.public boolean isSubmit()
Indicates whether the form should be submitted when the menu item is selected. By default, the form will only be submitted if an action has been set on this item.
Examples of where the form might should not be submitted include if the menu item is within a sub-menu which supports multiple selection, or if the menu item points at an external URL.
public String getText()
public void setText(String text)
text
- the text to set.public String getTargetWindow()
public void setTargetWindow(String targetWindow)
targetWindow
- the target window name.@Deprecated public Boolean isSelectable()
getSelectability()
instead.@Deprecated public void setSelectable(Boolean selectable)
setSelectability(java.lang.Boolean)
instead.selectable
- true if this item is selectable, false if not, or null to default to the container.public boolean isSelected()
isSelected
in interface MenuItemSelectable
public Boolean getSelectability()
MenuItemSelectable.isSelectAllowed()
.getSelectability
in interface MenuItemSelectable
public void setSelectability(Boolean selectability)
setSelectability
in interface MenuItemSelectable
selectability
- true if this item is selectable, false if not, or null to default to the container.public boolean isDisabled()
isDisabled
in interface Disableable
public boolean isSelectAllowed()
isSelectAllowed
in interface MenuItemSelectable
true
if a WMenuItem is allowed to have a selection state. This is determined by its nearest
ancestor MenuSelectContainer
's selectionMode.public void setDisabled(boolean disabled)
setDisabled
in interface Disableable
disabled
- true to set the item disabled, false for enabled.public final boolean isTopLevelItem()
true
if the WMenuItem is either an immediate child of a WMenu or an immediate child of a
WMenuItemGroup which is itself an immediate child of a WMenu.public char getAccessKey()
getAccessKey
in interface AccessKeyable
public void setAccessKey(char accessKey)
AccessKeyable
setAccessKey
in interface AccessKeyable
accessKey
- the key that will form a keyboard shortcut to the component.public String getActionCommand()
public void setActionCommand(String actionCommand)
actionCommand
- The actionCommand to set.public Serializable getActionObject()
public void setActionObject(Serializable actionObject)
actionObject
- The actionObject to set.public String getMessage()
public void setMessage(String message, Serializable... args)
message
- the confirmation message to display, using MessageFormat
syntax.args
- optional arguments for the message format string.public boolean isCancel()
public void setCancel(boolean cancel)
cancel
- true if menu item is a cancel control and will warn the user of unsaved changes, otherwise falsepublic void handleRequest(Request request)
handleRequest
in interface WComponent
handleRequest
in class AbstractWComponent
request
- the request being responded to.protected boolean isMenuPresent(Request request)
request
- the request being responded to.public String toString()
AbstractWComponent
toString
in class AbstractWComponent
protected WMenuItem.MenuItemModel newComponentModel()
newComponentModel
in class AbstractWComponent
protected WMenuItem.MenuItemModel getComponentModel()
getComponentModel
in class AbstractWComponent
protected WMenuItem.MenuItemModel getOrCreateComponentModel()
getOrCreateComponentModel
in class AbstractWComponent
Copyright © 2021. All rights reserved.