Interface Link

  • All Known Implementing Classes:
    LinkImpl

    public interface Link
    A link is the Tapestry representation of a URL or URI that triggers dynamic behavior. This link is in three parts: a path portion, an optional anchor, and a set of query parameters. A request for a link will ultimately be recognized by a Dispatcher. Query parameter values are kept separate from the path portion to support encoding those values into hidden form fields (where appropriate).
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      Link  parameterName,  value)
      Adds a parameter value.
      Link  parameterName,  value)
      Adds a parameter value as a value object; the value object is converted to a string via from tapestry-core and the result is added via addParameter(String, String).
      Link  basePath)
      Creates a copy of this link that has the same parameters, anchor, and other attributes, but a different base path.
      getAnchor()
      Returns the link anchor.
      getBasePath()
      Returns the completely unadorned base path.
      <> getParameterNames()
      Returns the names of any additional query parameters for the URI.
       name)
      Returns the value of a specifically named query parameter, or null if no such query parameter is stored in the link.
      []  parameterName)
      Returns the parameter values for the given name.
      LinkSecurity getSecurity()
      Returns the current security for this link, which reflects whether the targeted page is itself secure or insecure.
      Link  parameterName)
      Removes a parameter value, which is occasionally useful when transforming a parameter into a portion of the path.
      Link  anchor)
      Sets the link anchor.
      void setSecurity​(LinkSecurity newSecurity)
      Changes the link's security, which can be useful to force a link to be either secure or insecure when normally it might not be.
      toAbsoluteURI()
      Returns the absolute URL, which includes the scheme, hostname and possibly port (as per BaseURLSource.getBaseURL(boolean)).
      toAbsoluteURI​(boolean secure)
      Returns either the secure or insecure URL, with complete scheme, hostname and possibly port (as per BaseURLSource.getBaseURL(boolean)).
      toRedirectURI()
      Returns the link as a redirect URI.
      toURI()
      Returns the URI portion of the link.
    • Method Detail

      • getParameterNames

        <> getParameterNames()
        Returns the names of any additional query parameters for the URI. Query parameters store less regular or less often used values that can not be expressed in the path. They also are used to store, or link to, persistent state.
        Returns:
        list of query parameter names, is alphabetical order
      • getParameterValue

          name)
        Returns the value of a specifically named query parameter, or null if no such query parameter is stored in the link. Use this method only when you are sure the parameter has only one value. If the parameter might have more than one value, use getParameterValues(java.lang.String). If you use this method with a multivalued parameter, the value returned is equal to the first value in the array returned by getParameterValues.
        Returns:
        a string representing the single value of the named parameter
      • addParameter

        @IncompatibleChange(release="5.4",
                            details="changed from void to Link")
         parameterName,
                           value)
        Adds a parameter value. The value will be added, as is, to the URL. In many cases, the value should be URL encoded via URLCodec.
        Parameters:
        parameterName - the name of the parameter to store
        value - the value to store, a null or blank value is allowed (as of Tapestry 5.3)
        Returns:
        this Link, to support method chaining
      • addParameterValue

         parameterName,
                                value)
        Adds a parameter value as a value object; the value object is converted to a string via from tapestry-core and the result is added via addParameter(String, String). The Link object is returned for further configuration.
        Since:
        5.2.2
      • removeParameter

        @IncompatibleChange(release="5.4",
                            details="changed from void to Link")
         parameterName)
        Removes a parameter value, which is occasionally useful when transforming a parameter into a portion of the path.
        Returns:
        this Link, to support method chaining
        Since:
        5.2.0
      • getBasePath

         getBasePath()
        Returns the completely unadorned base path. Other methods (such as toURI()), may append an anchor or query parameters.
        Since:
        5.2.0
      • copyWithBasePath

         basePath)
        Creates a copy of this link that has the same parameters, anchor, and other attributes, but a different base path.
        Returns:
        a new Link instance
        Since:
        5.2.0
      • toURI

         toURI()
        Returns the URI portion of the link. When the link is created for a form, this will not include query parameters. This is the same value returned from toString().
        Returns:
        the URI, ready to be added as an element attribute
      • toRedirectURI

         toRedirectURI()
        Returns the link as a redirect URI. The URI includes any query parameters.
      • getAnchor

         getAnchor()
        Returns the link anchor. If this link does not have an anchor, this method returns null.
        Returns:
        the link anchor
      • setAnchor

        @IncompatibleChange(release="5.4",
                            details="changed from void to Link")
         anchor)
        Sets the link anchor. Null and empty anchors will be ignored when building the link URI.
        Parameters:
        anchor - the link anchor
        Returns:
        this Link, to support method chaining
      • toAbsoluteURI

         toAbsoluteURI()
        Returns the absolute URL, which includes the scheme, hostname and possibly port (as per BaseURLSource.getBaseURL(boolean)). By default, the scheme is chosen to match the security of the current request. Note: the semantics of this method changed between Tapestry 5.1 and 5.2. Most code should use toString() or toURI() (which are equivalent) instead.
        Returns:
        the complete, qualified URL, including query parameters.
      • toAbsoluteURI

         toAbsoluteURI​(boolean secure)
        Returns either the secure or insecure URL, with complete scheme, hostname and possibly port (as per BaseURLSource.getBaseURL(boolean)).
        Returns:
        the complete, qualified URL, including query parameters.
        Since:
        5.2.2
      • getSecurity

        @IncompatibleChange(release="5.4",
                            details="LinkSecurity class moved from internal package to org.apache.tapestry5.")
        LinkSecurity getSecurity()
        Returns the current security for this link, which reflects whether the targeted page is itself secure or insecure.
        Since:
        5.3
      • getParameterValues

        []  parameterName)
        Returns the parameter values for the given name. Returns null if no such parameter is stored in the link.