Class WMenuItem

    • Constructor Detail

      • WMenuItem

        public WMenuItem​(WDecoratedLabel label)
        Creates a WMenuItem with the given label.
        Parameters:
        label - the menu item label.
      • WMenuItem

        public WMenuItem​(WDecoratedLabel label,
                         String url)
        Creates a WMenuItem with the given label and url.
        Parameters:
        label - the menu item label.
        url - the URL to navigate to when the menu item is invoked.
      • WMenuItem

        public WMenuItem​(WDecoratedLabel label,
                         Action action)
        Creates a WMenuItem with the given label and action.
        Parameters:
        label - the menu item label.
        action - the action to execute when the menu item is invoked.
      • WMenuItem

        public WMenuItem​(String text,
                         String url)
        Creates a WMenuItem with the given text and url.
        Parameters:
        text - the menu item text.
        url - the URL to navigate to when the menu item is invoked.
      • WMenuItem

        public WMenuItem​(String text,
                         Action action)
        Creates a WMenuItem with the given label and action.
        Parameters:
        text - the menu item text.
        action - the action to execute when the menu item is invoked.
      • WMenuItem

        public WMenuItem​(String text)
        Creates a new WMenuItem with the specified text.
        Parameters:
        text - the menu item's text.
      • WMenuItem

        public WMenuItem​(String text,
                         char accessKey)
        Creates a new WMenuItem with the specified text and accessKey.
        Parameters:
        text - the menu item's text.
        accessKey - the menu item's access key.
      • WMenuItem

        public WMenuItem​(String text,
                         char accessKey,
                         Action action)
        Creates a new WMenuItem with the specified text, accessKey and action.
        Parameters:
        text - the menu item's text.
        accessKey - the menu item's access key.
        action - the action to execute when the menu item is invoked.
    • Method Detail

      • getDecoratedLabel

        public WDecoratedLabel getDecoratedLabel()
        Returns:
        the decorated label which displays the menu item's text/icon etc.
      • getAction

        public Action getAction()
        Returns:
        the menu item's action, or null if there is no action specified.
      • setAction

        public void setAction​(Action action)
        Sets the action to execute when the menu item is invoked.
        Parameters:
        action - the menu item's action.
      • getUrl

        public String getUrl()
        Retrieves the menu item's URL.
        Returns:
        the menu item's url, or null if there is no url specified.
      • setUrl

        public void setUrl​(String url)
        Sets the URL to navigate to when the menu item is invoked.
        Parameters:
        url - the url to set.
      • isSubmit

        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.

        Returns:
        true if the form should be submitted when the menu item is selected.
      • getText

        public String getText()
        Retrieves the menu item text.
        Returns:
        the menu item text
      • setText

        public void setText​(String text)
        Sets the text of the menu item.
        Parameters:
        text - the text to set.
      • getTargetWindow

        public String getTargetWindow()
        Retrieves the target window name.
        Returns:
        the target window name.
      • setTargetWindow

        public void setTargetWindow​(String targetWindow)
        Sets this menu item's target window name.
        Parameters:
        targetWindow - the target window name.
      • isSelectable

        @Deprecated
        public Boolean isSelectable()
        Deprecated.
        Use getSelectability() instead.
        Returns:
        true if this item is selectable, false if not, or null to default to the container.
      • isSelected

        public boolean isSelected()
        Specified by:
        isSelected in interface MenuItemSelectable
        Returns:
        true if selected, otherwise false
      • getSelectability

        public Boolean getSelectability()
        Symmetric accessor which should not generally be used. If you need to know if an instance of MenuItemSelectable is selectable then it is better to use MenuItemSelectable.isSelectAllowed().
        Specified by:
        getSelectability in interface MenuItemSelectable
        Returns:
        true if this item is selectable, false if not, or null if default to its container.
      • setSelectability

        public void setSelectability​(Boolean selectability)
        Specified by:
        setSelectability in interface MenuItemSelectable
        Parameters:
        selectability - true if this item is selectable, false if not, or null to default to the container.
      • isDisabled

        public boolean isDisabled()
        Indicates whether this menu item is disabled in the given context.
        Specified by:
        isDisabled in interface Disableable
        Returns:
        true if this menu item is disabled, false if it is enabled.
      • isSelectAllowed

        public boolean isSelectAllowed()
        Specified by:
        isSelectAllowed in interface MenuItemSelectable
        Returns:
        true if a WMenuItem is allowed to have a selection state. This is determined by its nearest ancestor MenuSelectContainer's selectionMode.
      • setDisabled

        public void setDisabled​(boolean disabled)
        Sets whether this menu item is disabled.
        Specified by:
        setDisabled in interface Disableable
        Parameters:
        disabled - true to set the item disabled, false for enabled.
      • isTopLevelItem

        public final boolean isTopLevelItem()
        Returns:
        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.
      • getAccessKey

        public char getAccessKey()
        Specified by:
        getAccessKey in interface AccessKeyable
        Returns:
        the component's access key.
      • setAccessKey

        public void setAccessKey​(char accessKey)
        Description copied from interface: AccessKeyable
        Set the access key on the component.
        Specified by:
        setAccessKey in interface AccessKeyable
        Parameters:
        accessKey - the key that will form a keyboard shortcut to the component.
      • getActionCommand

        public String getActionCommand()
        Retrieves this menu item's action command.
        Returns:
        the actionCommand.
      • setActionCommand

        public void setActionCommand​(String actionCommand)
        Sets this menu item's action command.
        Parameters:
        actionCommand - The actionCommand to set.
      • getActionObject

        public Serializable getActionObject()
        Retrieves this menu item's action object.
        Returns:
        the actionObject.
      • setActionObject

        public void setActionObject​(Serializable actionObject)
        Sets this menu item's action object.
        Parameters:
        actionObject - The actionObject to set.
      • getMessage

        public String getMessage()
        Returns:
        the confirmation message for the menu item.
      • setMessage

        public void setMessage​(String message,
                               Serializable... args)
        Sets the confirmation message that is to be displayed to the user for this menu item.
        Parameters:
        message - the confirmation message to display, using MessageFormat syntax.
        args - optional arguments for the message format string.
      • isCancel

        public boolean isCancel()
        Returns:
        true if menu item is a cancel control and will warn the user of unsaved changes, otherwise false
      • setCancel

        public void setCancel​(boolean cancel)
        Parameters:
        cancel - true if menu item is a cancel control and will warn the user of unsaved changes, otherwise false
      • handleRequest

        public void handleRequest​(Request request)
        Override handleRequest in order to perform processing for this component. This implementation checks for selection of the menu item, and executes the associated action if it has been set.
        Specified by:
        handleRequest in interface WComponent
        Overrides:
        handleRequest in class AbstractWComponent
        Parameters:
        request - the request being responded to.
      • isMenuPresent

        protected boolean isMenuPresent​(Request request)
        Determine if this WMenuItem's parent WMenu is on the Request.
        Parameters:
        request - the request being responded to.
        Returns:
        true if this WMenuItem's WMenu is on the Request, otherwise return false.
      • toString

        public String toString()
        Description copied from class: AbstractWComponent
        Creates a String representation of this component; usually for debugging purposes.
        Overrides:
        toString in class AbstractWComponent
        Returns:
        a String representation of this component, for debugging purposes.
      • getComponentModel

        protected WMenuItem.MenuItemModel getComponentModel()
        Returns the effective component model for this component. Subclass may override this method to narrow the return type to their specific model type.
        Overrides:
        getComponentModel in class AbstractWComponent
        Returns:
        the effective component model
      • getOrCreateComponentModel

        protected WMenuItem.MenuItemModel getOrCreateComponentModel()
        Retrieves the model for this component so that it can be modified. If this method is called during request processing, and a session specific model does not yet exist, then a new model is created. Subclasses may override this method to narrow the return type to their specific model type.
        Overrides:
        getOrCreateComponentModel in class AbstractWComponent
        Returns:
        the model for this component