Class Anchor

    • Method Detail

      • setHref

        public void setHref​(String href)
        Sets the URL that this anchor links to.

        A disabled Anchor removes the attribute from the HTML element, but it is stored (and reused when enabled again) in the server-side component.

        Use the method removeHref() to remove the href attribute instead of setting it to an empty string.

        Parameters:
        href - the href to set
        See Also:
        removeHref(), setHref(AbstractStreamResource)
      • removeHref

        public void removeHref()
        Removes href attribute.
        See Also:
        setHref(String)
      • setHref

        public void setHref​(AbstractStreamResource href)
        Sets the URL that this anchor links to with the URL of the given StreamResource.
        Parameters:
        href - the resource value, not null
      • getHref

        public String getHref()
        Gets the URL that this anchor links to.
        Returns:
        the href value, or "" if no href has been set
        See Also:
        setHref(String)
      • setTarget

        public void setTarget​(String target)
        Sets the target window, tab or frame for this anchor. The target is either the window.name of a specific target, or one of these special values:
        • _self: Open the link in the current context. This is the default behavior.
        • _blank: Opens the link in a new unnamed context.
        • _parent: Opens the link in the parent context, or the current context if there is no parent context.
        • _top: Opens the link in the top most grandparent context, or the current context if there is no parent context.
        Parameters:
        target - the target value, or "" to remove the target value
      • getTarget

        public Optional<String> getTarget()
        Gets the target window, tab or frame name for this anchor.
        Returns:
        an optional target, or an empty optional if no target has been set
        See Also:
        setTarget(String)
      • setTarget

        public void setTarget​(AnchorTargetValue target)
        Sets the target window, tab or frame for this anchor. The target may be the one of these special values:
        • AnchorTarget.DEFAULT: Removes the target value. This has the same effect as setting the target to AnchorTarget.SELF.
        • AnchorTarget.SELF: Opens the link in the current context.
        • AnchorTarget.BLANK: Opens the link in a new unnamed context.
        • AnchorTarget.PARENT: Opens the link in the parent context, or the current context if there is no parent context.
        • AnchorTarget.TOP: Opens the link in the top most grandparent context, or the current context if there is no parent context.
        Parameters:
        target - the target value, not null