Class Anchor

    • Method Detail

      • setUnsafeHref

        public void setUnsafeHref​(String href)
        Sets the URL that this anchor links to without validating its scheme.

        Unlike setHref(String), this method does not reject URLs based on the "safeUrlSchemes" configuration. Use it only for URLs that are fully under your control and known to be safe, such as a hard-coded javascript: or data: URL. Passing untrusted input here can expose the application to cross-site scripting (XSS) attacks.

        Parameters:
        href - the href to set
        See Also:
        setHref(String)
      • 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