Class WLink

    • Constructor Detail

      • WLink

        public WLink()
        Creates a WLink.
      • WLink

        public WLink​(String text,
                     String url)
        Creates a WLink with the given text and url.
        Parameters:
        text - the link test to display.
        url - the link url.
    • Method Detail

      • getTargetWindowName

        public String getTargetWindowName()
        The name of the target popup window. Has no meaning when the link is not a popup.
        Returns:
        the target window name.
      • setTargetWindowName

        public void setTargetWindowName​(String targetWindowName)
        The name of the target popup window. Has no meaning when the link is not a popup.
        Parameters:
        targetWindowName - The targetWindowName to set.
      • getText

        public String getText()
        Return the default text displayed on the link.
        • else user text if set
        • else shared text if set
        • user value if set
        • bean value if present
        • else shared value
        Returns:
        the link text.
      • setText

        public void setText​(String text,
                            Serializable... args)
        Sets the text displayed on the link.
        Parameters:
        text - the text to set, using MessageFormat syntax.
        args - optional arguments for the message format string.
      • getUrl

        public String getUrl()
        Returns:
        the URL.
      • setUrl

        public void setUrl​(String url)
        Sets the URL.
        Parameters:
        url - the URL to set.
      • 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.
      • isDisabled

        public boolean isDisabled()
        Indicates whether this link is disabled in the given context.
        Specified by:
        isDisabled in interface Disableable
        Returns:
        true if this link is disabled, otherwise false.
      • setDisabled

        public void setDisabled​(boolean disabled)
        Sets whether this link is disabled by default.
        Specified by:
        setDisabled in interface Disableable
        Parameters:
        disabled - true if this link is to disabled by default, false for enabled.
      • getRel

        public String getRel()
        Returns:
        the relationship of the link's target to the current page.
      • setRel

        public void setRel​(String rel)
        Sets the relationship of the link's target to the current page.
        Parameters:
        rel - the relationship to set.
        See Also:
        Links in html docuemnts
      • getOpenNewWindow

        public boolean getOpenNewWindow()
        Indicates whether this link should open in a new window.
        Returns:
        true if the link should open in a new window, false if it should re-use the existing window.
      • setOpenNewWindow

        public void setOpenNewWindow​(boolean openNewWindow)
        Sets whether this link should open in a new window.
        Parameters:
        openNewWindow - true to open in a new window, false to re-use the existing window.
      • getWindowAttrs

        public WLink.WindowAttributes getWindowAttrs()
        Retrieves the attributes for new windows which are opened.

        To change attributes for individual users, set a new WLink.WindowAttributes object for each user.

        Returns:
        the attributes for new windows.
      • setWindowAttrs

        public void setWindowAttrs​(WLink.WindowAttributes windowAttrs)
        Parameters:
        windowAttrs - the attributes for new windows which are opened.
      • isRenderAsButton

        public boolean isRenderAsButton()
        Indicates whether this link should render as a button.
        Returns:
        true if this link should render as a button, false for a hyperlink.
      • setRenderAsButton

        public void setRenderAsButton​(boolean renderAsButton)
        Sets whether this link should render as a button.
        Parameters:
        renderAsButton - true if this link should render as a button, false for a hyperlink.
      • getAction

        public Action getAction()
        Returns:
        the action to execute when the link is pressed.
      • setAction

        public void setAction​(Action action,
                              AjaxTarget... actionTargets)
        Sets the action that will run if the link is pressed.

        The intended use of this action is when the link opens a new window or launches another application such as "mailto".

        Parameters:
        action - the action to execute when the link is pressed.
        actionTargets - the targets to replace when the link is clicked.
      • getActionTargets

        public AjaxTarget[] getActionTargets()
        Returns:
        the targets to replace when the link with an action is clicked.
      • 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 Object getActionObject()
        Returns the data object that has been associated with this button, else null. For convenience, this data object is passed to the execute() method of the button's associated Action, in the ActionEvent parameter.
        Returns:
        the action object.
      • setActionObject

        public void setActionObject​(Serializable data)
        Associate this button with a data object that can be easily accessed in the execute() method of the button's associated Action.
        Parameters:
        data - the action object.
      • handleRequest

        public void handleRequest​(Request request)
        Override handleRequest in order to perform processing for this component. This implementation checks whether the link has been pressed via the current ajax operation.
        Specified by:
        handleRequest in interface WComponent
        Overrides:
        handleRequest in class AbstractWComponent
        Parameters:
        request - the request being responded to.
      • preparePaintComponent

        protected void preparePaintComponent​(Request request)
        Override preparePaintComponent to register an AJAX operation if this link has an action.
        Overrides:
        preparePaintComponent in class AbstractWComponent
        Parameters:
        request - the request being responded to.
      • getImage

        public Image getImage()
        Return the image to display on the link.
        Returns:
        the image.
      • setImage

        public void setImage​(Image image)
        Sets the image to display on the link.
        Parameters:
        image - the image, or null for no image.
      • setImage

        public void setImage​(String image)
        Sets the image to display on the link. The image will be read from the application's class path rather than from its web docs.
        Parameters:
        image - the relative path to the image resource, or null for no image.
      • getImageHolder

        public WImage getImageHolder()
        Return the WImage used by this link to hold the Image resource.

        If the link is not using an Image resource, it will return null.

        Returns:
        the WImage holding the Image resource, or null if the link is not using an Image resource.
      • getImageUrl

        public String getImageUrl()
        Return the URL of the image to display on the link.
        Returns:
        the image url.
      • setImageUrl

        public void setImageUrl​(String imageUrl)
        Sets the URL of the image to display on the link.
        Parameters:
        imageUrl - the image url, or null for no image.
      • getImagePosition

        public WLink.ImagePosition getImagePosition()
        Returns:
        the position of the image
      • setImagePosition

        public void setImagePosition​(WLink.ImagePosition imagePosition)
        The position of the image on the link.
        Parameters:
        imagePosition - the position of the image
      • 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.
      • getChildCount

        public int getChildCount()
        Specified by:
        getChildCount in interface Container
        Returns:
        the number of child components currently contained within this component.
      • getChildAt

        public WComponent getChildAt​(int index)
        Retrieves a child component by its index.
        Specified by:
        getChildAt in interface Container
        Parameters:
        index - the index of the child component to be retrieved.
        Returns:
        the child component at the given index.
      • getIndexOfChild

        public int getIndexOfChild​(WComponent childComponent)
        Retrieves the index of the given child.
        Specified by:
        getIndexOfChild in interface Container
        Parameters:
        childComponent - the child component to retrieve the index for.
        Returns:
        the index of the given child component, or -1 if the component is not a child of this component.
      • getChildren

        public List<WComponent> getChildren()
        Retrieves a list of this Container's.
        Specified by:
        getChildren in interface Container
        Returns:
        an immutable list of this Container.
      • getComponentModel

        protected WLink.LinkModel 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 WBeanComponent
        Returns:
        the effective component model
      • getOrCreateComponentModel

        protected WLink.LinkModel 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 WBeanComponent
        Returns:
        the model for this component