org.apache.tapestry5.corelib.base

## Class AbstractLink

- java.lang.Object
- - org.apache.tapestry5.corelib.base.AbstractLink

- All Implemented Interfaces:
    ClientElement
  Direct Known Subclasses:
    AbstractComponentEventLink, PageLink

      @SupportsInformalParameters
      public abstract class AbstractLink
      extends Object
      implements ClientElement

  Provides base utilities for classes that generate clickable links.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected ComponentResources` | `resources`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractLink()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `addParameters(Link link)` Adds any user-defined parameters as query parameters.
    `String` | `getClientId()` Returns the unique client id for this element.
    `Link` | `getLink()` Returns the most recently rendered `Link` for this component.
    `boolean` | `isDisabled()` Returns true if the component is disabled (as per its disabled parameter).
    `protected void` | `writeLink(MarkupWriter writer, Link link, Object... namesAndValues)` Writes an <a> element with the provided link as the href attribute.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### resources

          @Inject
          protected ComponentResources resources

  - ### Constructor Detail

    - #### AbstractLink

          public AbstractLink()

  - ### Method Detail

    - #### writeLink

          protected final void writeLink(MarkupWriter writer,
                                         Link link,
                                         Object... namesAndValues)

      Writes an <a> element with the provided link as the href attribute. A call to `MarkupWriter.end()` is not provided. Automatically appends an anchor if the component's anchor parameter is non-null. Informal parameters are rendered as well.
      Parameters:
        `writer` - to write markup to
        `link` - the link that will form the href
        `namesAndValues` - additional attributes to write

    - #### addParameters

          protected final void addParameters(Link link)

      Adds any user-defined parameters as query parameters.
      Parameters:
        `link` - a `Link`.

    - #### getLink

          public Link getLink()

      Returns the most recently rendered `Link` for this component. Subclasses calculate their link value as they render, and the value is valid until the end of the request, or the next time the same component renders itself (if inside a loop).
      Returns:
        the most recent link, or null

    - #### getClientId

          public final String getClientId()

      Returns the unique client id for this element. This is valid only after the component has rendered (its start tag). A client id is generated the first time this method is invoked, after the link renders its start tag.
      Specified by:
        `getClientId` in interface `ClientElement`
      Returns:
        a unique id for the element. This value will be unique for any given rendering of a page. This value is intended for use as the id attribute of the client-side element, and will be used with any DHTML/Ajax related JavaScript.

    - #### isDisabled

          public boolean isDisabled()

      Returns true if the component is disabled (as per its disabled parameter). Disabled link components should not render a tag, but should still render their body.
      Returns:
        `true` or `false`.

5.6.0 - Copyright © 2003-2020 The Apache Software Foundation.