com.arsdigita.bebop
Class BaseLink

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

public abstract class BaseLink
extends TextStylable
implements Cloneable

The parent of all Bebop Link classes, this class represents a URL on a page. It may contain a label, an image, or any other component.

The following table lists all Bebop Link classes and suggests when they might be used.

Link Class Usage
BaseLink Parent class of Bebop Link classes. Extend this class to build your own Link class.
Link Link class that manages its own URL variables. Session information is added to the target URL for this type.
ExternalLink Link that does not encode the URL with any session information. Used for a link to a page outside the site.
ControlLink Used for references within its own page (often as fields in a table header for sorting a column).
ActionLink Sets its own control event and runs its own ActionListeners. When the link is clicked, the code in the Listener's actionPerformed method runs.
ToggleLink A link that turns into label when it is selected and turns back into a link when it is unselected.


Field Summary
protected  Component m_child
           
protected  String m_noJavascriptURL
           
protected  String m_url
           
static String versionId
           
 
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
BaseLink(Component child, PrintListener l)
           
BaseLink(Component child, String url)
           
BaseLink(PrintListener l)
           
BaseLink(String label, PrintListener l)
           
BaseLink(String label, String url)
           
 
Method Summary
 void addPrintListener(PrintListener listener)
          Adds a print listener.
 Object clone()
          Clones a component.
protected  BaseLink firePrintEvent(PageState state)
           
protected  void generateExtraXMLAttributes(PageState state, Element link)
          Adds type-specific XML attributes to the XML element representing this link.
protected abstract  void generateURL(PageState state, Element parent)
           
 void generateXML(PageState state, Element parent)
          Generates a DOM fragment:
 Component getChild()
           
 String getNoJavascriptTarget()
           
 String getTarget()
           
 void removePrintListener(PrintListener listener)
          Removes a previously added print listener.
 void setChild(Component child)
           
 void setConfirmation(String message)
          Forces the user to click through a confirmation dialog before this link is followed.
 void setNoJavascriptTarget(String sURL)
           
 void setOnClick(String value)
          Sets onClick event.
 void setTarget(String url)
           
protected  void setTypeAttr(String t)
          Sets the type of link this link represents.
protected  void setupNoJavascriptURL(PageState ps, Element link)
           
 
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

m_url

protected String m_url

m_noJavascriptURL

protected String m_noJavascriptURL

m_child

protected Component m_child
Constructor Detail

BaseLink

public BaseLink(Component child,
                String url)

BaseLink

public BaseLink(String label,
                String url)

BaseLink

public BaseLink(Component child,
                PrintListener l)

BaseLink

public BaseLink(String label,
                PrintListener l)

BaseLink

public BaseLink(PrintListener l)
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 SimpleComponent
Returns:
the clone of a component.
Throws:
CloneNotSupportedException

addPrintListener

public void addPrintListener(PrintListener listener)
                      throws IllegalStateException,
                             TooManyListenersException
Adds a print listener. Since the PrintListener is expected to modify the target of the PrintEvent, only one print listener can be set for a link.

Parameters:
listener - the print listener
Throws:
IllegalArgumentException - if listener is null.
TooManyListenersException - if a print listener has previously been added.
IllegalStateException

removePrintListener

public void removePrintListener(PrintListener listener)
                         throws IllegalArgumentException
Removes a previously added print listener. If the passed in listener is not the listener that was added with addPrintListener, an IllegalArgumentException will be thrown.

Parameters:
listener - the listener that was previously added with addPrintListener
Throws:
IllegalArgumentException - if listener is not the currently registered print listener or is null.

firePrintEvent

protected BaseLink firePrintEvent(PageState state)

getChild

public final Component getChild()

setChild

public void setChild(Component child)

getTarget

public final String getTarget()

setTarget

public final void setTarget(String url)

setTypeAttr

protected void setTypeAttr(String t)
Sets the type of link this link represents.

Parameters:
t - the type of link

generateURL

protected abstract void generateURL(PageState state,
                                    Element parent)

generateXML

public void generateXML(PageState state,
                        Element parent)

Generates a DOM fragment:

 <bebop:link href="..." type="..." %bebopAttr;/>
 
The href attribute contains the target the link should point to. The type attribute is used to give more finegrained control over which kind of link this element represents. The types are link for a Link, control for a ControlLink, and toggle for a ToggleLink. There may be additional attributes depending on what type of link this link represents.

Specified by:
generateXML in interface Component
Overrides:
generateXML in class SimpleComponent
See Also:
generateXML(com.arsdigita.bebop.PageState, com.arsdigita.xml.Element), ToggleLink.generateXML(com.arsdigita.bebop.PageState, com.arsdigita.xml.Element)

setupNoJavascriptURL

protected void setupNoJavascriptURL(PageState ps,
                                    Element link)

generateExtraXMLAttributes

protected void generateExtraXMLAttributes(PageState state,
                                          Element link)
Adds type-specific XML attributes to the XML element representing this link. Subclasses should override this method if they introduce more attributes than the ones generateXML produces by default.

Parameters:
state - the current request
link - the XML element representing this link

setOnClick

public void setOnClick(String value)
Sets onClick event. Not for confirmation messages; Should call setConfirmation for that.

Parameters:
value -
See Also:
setConfirmation(java.lang.String)

setConfirmation

public void setConfirmation(String message)
Forces the user to click through a confirmation dialog before this link is followed. The user is prompted with the specified message. If the user does not does not confirm, the link is not followed. The current implementation uses the JavaScript confirm function and the onClick attribute. If JavaScript is not enabled in the client browser, this method will redirect the browser to a Bebop confirmation page rather than use a JavaScript confirmation. Subsequent calls to setOnClick will undo the effect of this method.

Parameters:
message - the confirmation message presented to the user. This message cannot have an apostrophe or back slash

setNoJavascriptTarget

public final void setNoJavascriptTarget(String sURL)

getNoJavascriptTarget

public final String getNoJavascriptTarget()


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