com.arsdigita.bebop
Class Link

java.lang.Object
  extended bycom.arsdigita.bebop.Completable
      extended bycom.arsdigita.bebop.SimpleComponent
          extended bycom.arsdigita.bebop.TextStylable
              extended bycom.arsdigita.bebop.BaseLink
                  extended bycom.arsdigita.bebop.Link
All Implemented Interfaces:
Cloneable, Component, Lockable
Direct Known Subclasses:
ExternalLink

public class Link
extends BaseLink

A URL on a page. May contain a label, an image, or any other component. A Link is a BaseLink that manages URL variables.

Example: The common usage for a Link component is illustrated in the code fragment below:

  Page p = new Page("Link Example");
  Link link = new Link("Click Here","path/to/target/");
  link.setVar("foo","1");
  p.add(link);
 

The target of the link above will be rendered in HTML as: href="path/to/target/?foo=1" If either the link text or the URL needs to be changed for a link within a locked page, a PrintListener should be used.


Field Summary
static String NEW_FRAME
          Passing this value to setTargetFrame will create a link that opens a new browser window whenever it is clicked.
protected  String TYPE_LINK
          The value for the XML type attribute for a plain link.
static String versionId
           
 
Fields inherited from class com.arsdigita.bebop.BaseLink
m_child, m_noJavascriptURL, m_url
 
Fields inherited from class com.arsdigita.bebop.SimpleComponent
m_attr
 
Fields inherited from interface com.arsdigita.bebop.Component
BEBOP_XML_NS, CLASS, ID, ON_CLICK, STYLE
 
Constructor Summary
Link(Component child, PrintListener l)
          Constructors with PrintListener parameters allow for a PrintListener to be set for the Link, without the need to make a separate call to the addPrintListener method.
Link(Component child, String url)
          The Component parameter in this constructor is usually a Label or Image.
Link(PrintListener l)
           
Link(String label, PrintListener l)
           
Link(String label, String url)
          This constructor is a common one for a Link component, as it allows for the Link text and the target URL to be set at the same time during construction.
Link(String label, URL url)
          Constructs a Link using a URL.
 
Method Summary
 void addURLVars(String name, String value)
          Deprecated. use setVar
 Object clone()
          Clones a component.
protected  void generateURL(PageState state, Element parent)
           
 String getTargetFrame()
          Get the "target" attribute of the link, which determines which browser frame will load the new page when this link is clicked.
 String getURLVarString()
           
protected  String prepareURL(PageState state, String location)
          Processes the URL for this link after the print listener runs.
 void setTargetFrame(String frameName)
          Set the "target" attribute of the link, which determines which browser frame will load the new page when this link is clicked.
 void setVar(String name, String value)
          Sets a query variable and its value.
 
Methods inherited from class com.arsdigita.bebop.BaseLink
addPrintListener, firePrintEvent, generateExtraXMLAttributes, generateXML, getChild, getNoJavascriptTarget, getTarget, removePrintListener, setChild, setConfirmation, setNoJavascriptTarget, setOnClick, setTarget, setTypeAttr, setupNoJavascriptURL
 
Methods inherited from class com.arsdigita.bebop.TextStylable
setBackgroundColor, setColor
 
Methods inherited from class com.arsdigita.bebop.SimpleComponent
children, exportAttributes, getAttribute, getClassAttr, getIdAttr, getKey, getMetaDataAttribute, getStyleAttr, hasAttributes, isLocked, isVisible, lock, register, register, respond, setAttribute, setClassAttr, setIdAttr, setKey, setMetaDataAttribute, setStyleAttr, setVisible
 
Methods inherited from class com.arsdigita.bebop.Completable
addCompletionListener, fireCompletionEvent
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values

TYPE_LINK

protected final String TYPE_LINK
The value for the XML type attribute for a plain link.

See Also:
Constant Field Values

NEW_FRAME

public static final String NEW_FRAME

Passing this value to setTargetFrame will create a link that opens a new browser window whenever it is clicked.

See Also:
setTargetFrame(java.lang.String), Constant Field Values
Constructor Detail

Link

public Link(Component child,
            String url)

The Component parameter in this constructor is usually a Label or Image.

Starting with release 5.2, this method prefixes the passed-in url with the path to the CCM dispatcher. Code using this constructor should not prefix url with the webapp context path or the dispatcher servlet path.

The vast majority of CCM UI code expects to link through the dispatcher. Code that does not should use the Link constructor taking a URL.

See Also:
Link(String,URL)

Link

public Link(Component child,
            PrintListener l)
Constructors with PrintListener parameters allow for a PrintListener to be set for the Link, without the need to make a separate call to the addPrintListener method. PrintListeners are a convenient way to alter underlying Link attributes such as Link text or target URL within a locked page on a per request basis.


Link

public Link(String label,
            PrintListener l)

Link

public Link(PrintListener l)

Link

public Link(String label,
            String url)

This constructor is a common one for a Link component, as it allows for the Link text and the target URL to be set at the same time during construction.

Starting with release 5.2, this method prefixes the passed-in url with the path to the CCM dispatcher. Code using this constructor should not prefix url with the webapp context path or the dispatcher servlet path.

The vast majority of CCM UI code expects to link through the dispatcher. Code that does not should use the Link constructor taking a URL.

See Also:
Link(String,URL)

Link

public Link(String label,
            URL url)

Constructs a Link using a URL. When this constructor is used, the method setVar(String,String) and its deprecated equivalent have no effect on the resulting hyperlink. Instead, use the ParameterMap argument to URL.

Parameters:
label - a String of label text
url - a URL for the link's target
See Also:
URL, ParameterMap
Method Detail

clone

public Object clone()
             throws CloneNotSupportedException
Description copied from class: SimpleComponent
Clones a component. The clone is not locked and has its own set of attributes.

Overrides:
clone in class BaseLink
Throws:
CloneNotSupportedException

setVar

public void setVar(String name,
                   String value)
Sets a query variable and its value. Overwrites any values that may have been set previously under the specified name.

All the variables set with this method are appended to the query string in the URL that is output for this Link.

Parameters:
name - the name of the query
value - the value for the query

addURLVars

public void addURLVars(String name,
                       String value)
Deprecated. use setVar

Set a query variable and its value


getURLVarString

public String getURLVarString()

getTargetFrame

public String getTargetFrame()

Get the "target" attribute of the link, which determines which browser frame will load the new page when this link is clicked.


setTargetFrame

public void setTargetFrame(String frameName)

Set the "target" attribute of the link, which determines which browser frame will load the new page when this link is clicked.


generateURL

protected void generateURL(PageState state,
                           Element parent)
Specified by:
generateURL in class BaseLink

prepareURL

protected String prepareURL(PageState state,
                            String location)
Processes the URL for this link after the print listener runs.

Parameters:
location - the original URL
Returns:
the URL appended with ACS-specific URL parameters.


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC