Class LinkTag

All Implemented Interfaces:
Serializable, IterationTag, JspTag, Tag
Direct Known Subclasses:
CommandLinkTag, ScrollTag

public class LinkTag extends ElementTag
A JSP tag to generate an HTML link.
Since:
1.0
Version:
7.4
Author:
Luke
See Also:
  • Constructor Details

    • LinkTag

      public LinkTag()
      Generates a new link tag.
  • Method Details

    • doStartTag

      public int doStartTag() throws JspException
      Opens this link element by writing an >A< tag.
      Specified by:
      doStartTag in interface Tag
      Overrides:
      doStartTag in class ElementTag
      Throws:
      JspException - if an error occurs;
    • doEndTag

      public int doEndTag() throws JspException
      Closes this link element by writing an >/A< tag.
      Specified by:
      doEndTag in interface Tag
      Overrides:
      doEndTag in class TagSupport
      Throws:
      JspException - if an I/O error occurs
    • setUrl

      public void setUrl(String url)
      Sets the target URL for this link.
      Parameters:
      url - the target URL
    • setOnClick

      public void setOnClick(String js)
      Sets the JavaScript onClick event for this link.
      Parameters:
      js - the JavaScript code to execute when this link is clicked
    • setAnchor

      public void setAnchor(String a)
      Sets the anchor for this link.
      Parameters:
      a - the anchor
    • setLabel

      public void setLabel(String label)
      Sets the label for this link.
      Parameters:
      label - the link label
    • setTarget

      public void setTarget(String targetFrame)
      Sets the target frame for this link.
      Parameters:
      targetFrame - the target frame name
    • setExternal

      public void setExternal(boolean isExternal)
      Marks this link as an external link.
      Parameters:
      isExternal - TRUE if the link is external, otherwise FALSE
    • validateLink

      protected void validateLink() throws IllegalStateException
      Validates the tag to ensure a URL/onClick event has been set.
      Throws:
      IllegalStateException - if neither a URL nor onClick are present
    • release

      public void release()
      Releases the tag's state variables.
      Specified by:
      release in interface Tag
      Overrides:
      release in class ElementTag