Class WLink


  • public class WLink
    extends java.lang.Object
    A value class that defines a hyperlink target.

    This class abstracts a link target. Depending on the context, it may reference a URL, a dynamic resource, or (for certain usages) an internal path.

    See Also:
    WAnchor, WImage, WMediaPlayer, WPushButton
    • Constructor Summary

      Constructors 
      Constructor Description
      WLink()
      Default constructor.
      WLink​(LinkType type, java.lang.String value)
      Creates a link to a (static) URL or an internal path.
      WLink​(WResource resource)
      Creates a link to a resource.
      WLink​(java.lang.String url)
      Creates a link to a (static) URL.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(WLink other)
      Indicates whether some other object is "equal to" this one.
      java.lang.String getInternalPath()
      Returns the internal path.
      WResource getResource()
      Returns the link resource.
      LinkTarget getTarget()
      Returns the location where the linked content should be displayed.
      LinkType getType()
      Returns the link type.
      java.lang.String getUrl()
      Returns the link URL.
      boolean isNull()
      Returns whether the link is unspecified.
      void setInternalPath​(java.lang.String internalPath)
      Sets the link internal path.
      void setResource​(WResource resource)
      Sets the link resource.
      void setTarget​(LinkTarget target)
      Sets the location where the linked content should be displayed.
      void setUrl​(java.lang.String url)
      Sets the link URL.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • isNull

        public boolean isNull()
        Returns whether the link is unspecified.

        A null link is a link created using the default constructor and points to nowhere.

        See Also:
        WLink()
      • setUrl

        public void setUrl​(java.lang.String url)
        Sets the link URL.

        This sets the type to LinkType.Url.

      • getUrl

        public java.lang.String getUrl()
        Returns the link URL.

        The return value is the URL set by setUrl(), the resource URL of the resource set using setResource(), or the canonical URL of an internal path within the current application context.

      • setInternalPath

        public void setInternalPath​(java.lang.String internalPath)
        Sets the link internal path.

        This points the link to the given internal path.

      • setTarget

        public void setTarget​(LinkTarget target)
        Sets the location where the linked content should be displayed.

        By default, the linked content is displayed in the application (LinkTarget.Self). When the destination is an HTML document, the application is replaced with the new document. When the link is to a document that cannot be displayed in the browser, it is offered for download or opened using an external program, depending on browser settings.

        By setting target to LinkTarget.NewWindow, the destination is displayed in a new browser window or tab.

        See Also:
        getTarget()
      • equals

        public boolean equals​(WLink other)
        Indicates whether some other object is "equal to" this one.