BEA Systems, Inc.

WebLogic Server 5.1.0 API Reference

weblogic.html
Class AnchorElement

java.lang.Object
  |
  +--weblogic.html.HtmlElement
        |
        +--weblogic.html.ElementWithAttributes
              |
              +--weblogic.html.SinglePartElement
                    |
                    +--weblogic.html.AnchorElement
Direct Known Subclasses:
LinkElement

public class AnchorElement
extends SinglePartElement

Use an AnchorElement object to create hypertext links in a document. This class supercedes LinkElement in version 1.0 and has support for HTML 4.0 attributes and some other extensions.

This example shows an AnchorElement added to an HtmlPage, "page," that points to copyright information. The first constructor argument is the url, the second is the displayed hyperlinked text, the third a target window.

  page.addElement(new AnchorElement("http://www.acme.com/copyright.html",
                                   "© 1996, Acme Inc. All Rights Reserved.",
                                    WindowName.parent));
 
These two examples show how to construct and set an AnchorElement as an internal link on a page:
  page.addElement(new HeadingElement(1, "Main Topic")
                     .asAnchorElement(new StringElement("#topic1")));
 
or,
  page.addElement(new StringElement("Instructions on "))
            .addElement(new AnchorElement(AnchorType.name,
                                          "#install",
                                          new StringElement("installing the kit")));
 

Author:
Copyright (c) 1995-97, WebLogic, Inc. All Rights Reserved.
Copyright © 2000 BEA Systems, Inc. All Rights Reserved.
See Also:
AnchorType

Fields inherited from class weblogic.html.HtmlElement
codeset, useObsolete
 
Constructor Summary
AnchorElement()
          Constructs an empty AnchorElement.
AnchorElement(AnchorType type, java.lang.String link, HtmlElement display)
          Constructs an AnchorElement of the specified type and link, and sets the contents of the anchor.
AnchorElement(AnchorType type, java.lang.String link, java.lang.String display)
          Constructs an AnchorElement of the specified type and link, and sets the contents of the anchor.
AnchorElement(HtmlElement display)
          Constructs a AnchorElement with the specified display information and no URL.
AnchorElement(java.lang.String url)
          Constructs a AnchorElement with the specified HREF tag.
AnchorElement(java.lang.String url, HtmlElement display)
          Constructs a AnchorElement with the specified URL and display information.
AnchorElement(java.lang.String url, HtmlElement display, java.lang.String target)
          Constructs an AnchorElement with the specified URL, sets the display information to the specified HtmlElement, and sets the display window to the specified string name.
AnchorElement(java.lang.String url, HtmlElement display, WindowName target)
          Constructs an AnchorElement with the specified URL, display information, and target.
AnchorElement(java.lang.String url, java.lang.String display)
          Constructs a AnchorElement with the specified link and display information.
AnchorElement(java.lang.String url, java.lang.String display, java.lang.String target)
          Constructs an AnchorElement with the specified URL, display information, and target.
AnchorElement(java.lang.String url, java.lang.String display, WindowName target)
          Constructs an AnchorElement with the specified URL, display information, and target.
 
Method Summary
protected  java.lang.String getHtmlCode()
           
protected  boolean printBody()
           
protected  boolean printCR()
           
protected  boolean printEndingTag()
           
 AnchorElement setHref(HtmlElement url)
          Sets the HREF attribute for an AnchorElement.
 AnchorElement setHref(java.lang.String url)
          Sets the HREF attribute for a AnchorElement.
 AnchorElement setName(java.lang.String name)
          Sets the NAME attribute for an AnchorElement.
 AnchorElement setOnClick(java.lang.String event)
          Sets the ONCLICK attribute for a AnchorElement.
 AnchorElement setOnMouseOver(java.lang.String event)
          Sets the ONMOUSEOVER attribute for a AnchorElement.
 AnchorElement setTabindex(int tabindex)
          Sets the tabbing order for an AnchorElement, which defines the order in which page elements get the focus when a user navigates the page with a keyboard.
 AnchorElement setTabindex(java.lang.String tabindex)
          Sets the TABINDEX attribute for an AnchorElement.
 AnchorElement setTarget(java.lang.String target)
          Sets the TARGET attribute for a AnchorElement.
 AnchorElement setTarget(WindowName target)
          Sets the TARGET attribute for a AnchorElement.
 AnchorElement setTitle(java.lang.String title)
          Sets the TITLE attribute for an AnchorElement.
 
Methods inherited from class weblogic.html.SinglePartElement
getElement, printBody, printBody, printBody, setElement, setElement, widthAsLiteral
 
Methods inherited from class weblogic.html.ElementWithAttributes
addAttribute, addAttribute, escapeQuotes, getBooleanAttribute, getElementAttribute, getLocalVar, getQuotedAttribute, output, output, output, setBooleanAttribute, setBooleanAttribute, setClass, setDirection, setElementAttribute, setElementAttribute, setElementAttribute, setElementAttribute, setElementAttribute, setId, setLang, setLocalVar, setQuotedAttribute, setStyle
 
Methods inherited from class weblogic.html.HtmlElement
asAnchorElement, asBigElement, asBlockquoteElement, asBoldElement, asCenteredElement, asCiteElement, asCodeElement, asCommentElement, asDefineTermElement, asEmphasisElement, asFontElement, asFontElement, asFontElement, asHtmlContainer, asItalicElement, asKeyboardElement, asLiteralElement, asParagraphElement, asSampleElement, asSmallElement, asStrikeElement, asStrongElement, asSubscriptElement, asSuperscriptElement, asTeletypeElement, asUnderlineElement, asVariableElement, getVersion, setAnchorMode, setCodeset, toString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AnchorElement

public AnchorElement()
Constructs an empty AnchorElement.

AnchorElement

public AnchorElement(java.lang.String url)
Constructs a AnchorElement with the specified HREF tag.

Parameters:
url - URL of the referenced link

AnchorElement

public AnchorElement(HtmlElement display)
Constructs a AnchorElement with the specified display information and no URL.

Parameters:
elem - HtmlElement displayed text

AnchorElement

public AnchorElement(java.lang.String url,
                     HtmlElement display)
Constructs a AnchorElement with the specified URL and display information.

Parameters:
url - URL
display - HtmlElement displayed text

AnchorElement

public AnchorElement(java.lang.String url,
                     java.lang.String display)
Constructs a AnchorElement with the specified link and display information.

Parameters:
url - URL
display - String displayed text

AnchorElement

public AnchorElement(AnchorType type,
                     java.lang.String link,
                     HtmlElement display)
Constructs an AnchorElement of the specified type and link, and sets the contents of the anchor. Use an AnchorType for the first argument.

Parameters:
type - Constant from AnchorType
link - Href or Name value
display - Text enclosed by the anchor

AnchorElement

public AnchorElement(AnchorType type,
                     java.lang.String link,
                     java.lang.String display)
Constructs an AnchorElement of the specified type and link, and sets the contents of the anchor. Use an AnchorType for the first argument.

Parameters:
type - Constant from AnchorType
link - Href or Name value
display - Text enclosed by the anchor

AnchorElement

public AnchorElement(java.lang.String url,
                     java.lang.String display,
                     java.lang.String target)
Constructs an AnchorElement with the specified URL, display information, and target.

Parameters:
url - URL
display - String displayed text
target - Window name

AnchorElement

public AnchorElement(java.lang.String url,
                     HtmlElement display,
                     java.lang.String target)
Constructs an AnchorElement with the specified URL, sets the display information to the specified HtmlElement, and sets the display window to the specified string name.

Parameters:
url - URL
display - HtmlElement displayed text
target - Window name

AnchorElement

public AnchorElement(java.lang.String url,
                     java.lang.String display,
                     WindowName target)
Constructs an AnchorElement with the specified URL, display information, and target.

Parameters:
url - URL
display - String displayed text
target - Window name

AnchorElement

public AnchorElement(java.lang.String url,
                     HtmlElement display,
                     WindowName target)
Constructs an AnchorElement with the specified URL, display information, and target.

Parameters:
url - URL
display - HtmlElement displayed text
target - Window name
Method Detail

getHtmlCode

protected java.lang.String getHtmlCode()

Overrides:
getHtmlCode in class ElementWithAttributes

printCR

protected boolean printCR()

Overrides:
printCR in class ElementWithAttributes

printBody

protected boolean printBody()

Overrides:
printBody in class ElementWithAttributes

printEndingTag

protected boolean printEndingTag()

Overrides:
printEndingTag in class ElementWithAttributes

setHref

public AnchorElement setHref(java.lang.String url)
Sets the HREF attribute for a AnchorElement.

Parameters:
url - HREF attribute
Returns:
AnchorElement object

setHref

public AnchorElement setHref(HtmlElement url)
Sets the HREF attribute for an AnchorElement. This value is not enclosed in double quotes.

Parameters:
url - HREF attribute
Returns:
AnchorElement

setName

public AnchorElement setName(java.lang.String name)
Sets the NAME attribute for an AnchorElement.

Parameters:
name - NAME attribute
Returns:
AnchorElement

setOnMouseOver

public AnchorElement setOnMouseOver(java.lang.String event)
Sets the ONMOUSEOVER attribute for a AnchorElement.

Parameters:
attrib - ONMOUSEOVER attribute
Returns:
AnchorElement object

setOnClick

public AnchorElement setOnClick(java.lang.String event)
Sets the ONCLICK attribute for a AnchorElement.

Parameters:
val - ONCLICK attribute
Returns:
AnchorElement object

setTabindex

public AnchorElement setTabindex(java.lang.String tabindex)
Sets the TABINDEX attribute for an AnchorElement. The tabindex attribute determines the tabbing order of selectable or clickable elements on a page.

Parameters:
tabindex - Index
Returns:
AnchorElement object

setTabindex

public AnchorElement setTabindex(int tabindex)
Sets the tabbing order for an AnchorElement, which defines the order in which page elements get the focus when a user navigates the page with a keyboard. This may be a positive or negative integer. Elements that are assigned the same tab index will be navigated in order of appearance on the page.

Parameters:
tabindex - int
Returns:
AnchorElement

setTarget

public AnchorElement setTarget(java.lang.String target)
Sets the TARGET attribute for a AnchorElement.

Parameters:
attrib - TARGET attribute
Returns:
AnchorElement object

setTarget

public AnchorElement setTarget(WindowName target)
Sets the TARGET attribute for a AnchorElement.

Parameters:
attrib - TARGET attribute
Returns:
AnchorElement object

setTitle

public AnchorElement setTitle(java.lang.String title)
Sets the TITLE attribute for an AnchorElement. This is most often used in "mailto" URLs to set the subject of the message.

Parameters:
title - String
Returns:
AnchorElement

Documentation is available at
http://www.weblogic.com/docs51