com.arsdigita.bebop
Class ControlLink

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.ControlLink
All Implemented Interfaces:
Cloneable, Component, Lockable
Direct Known Subclasses:
ActionLink, ToggleLink

public class ControlLink
extends BaseLink

A link back to the page in which it is contained. The control link captures and preserves the current state of the page, and possibly any control events that have been set. It is most useful inside a ListCellRenderer or a TableCellRenderer, where the list or table has already set up the events 'tight' for the control link to do the right thing.

Warning: Even though a control link lets you add action listeners, they are not run unless you override setControlEvent. If you need this behavior, you should use an ActionLink. A control link is hardly ever useful unless it is contained in an event-generating component like List or Table.

Example: A control link is mainly useful to send events to other components. For example, the following control link will cause a control event delete with associated value 42 to be sent to the component fooComponent when the user clicks on it:

    ControlLink l = new ControlLink("click here") {
      public void setControlEvent(PageState s) {
        s.setControlEvent(fooComponent, "delete", 42);
      }
    };
 

This requires that fooComponent is part of the page hierarchy. The control link l does not have to be part of the page hierarchy, and may be generated on the fly. (See PageState for details on control events.)

See BaseLink for a description of all Bebop Link classes.

Version:
$Id: //core-platform/dev/src/com/arsdigita/bebop/ControlLink.java#9 $
Author:
Stanislav Freidin, David Lutterkort

Field Summary
protected  String TYPE_CONTROL
          The XML type attribute for a ControlLink.
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
ControlLink(Component child)
          Constructs a new ControlLink.
ControlLink(String label)
          Constructs a new ControlLink with the given string label.
 
Method Summary
 void addActionListener(ActionListener l)
          Adds an ActionListener, which will be run when respond is called.
protected  void fireActionEvent(PageState state)
          Fires an ActionEvent, which causes all registered ActionListeners to be run.
protected  void generateURL(PageState state, Element parent)
          Generates the URL for a link and sets it as the "href" attribute of the parent.
 void removeActionListener(ActionListener l)
          Removes a previously added ActionListener.
 void respond(PageState state)
          Responds to the incoming request.
 void setControlEvent(PageState ps)
          Sets the page state's control event.
 
Methods inherited from class com.arsdigita.bebop.BaseLink
addPrintListener, clone, 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, 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_CONTROL

protected final String TYPE_CONTROL
The XML type attribute for a ControlLink.

See Also:
Constant Field Values
Constructor Detail

ControlLink

public ControlLink(Component child)
Constructs a new ControlLink. The link will encapsulates the child component (which should be a label or an image).

Parameters:
child - the component that will be turned into a link

ControlLink

public ControlLink(String label)
Constructs a new ControlLink with the given string label.

Parameters:
label - the string label for the link
Method Detail

addActionListener

public void addActionListener(ActionListener l)
Adds an ActionListener, which will be run when respond is called.

See Also:
respond

removeActionListener

public void removeActionListener(ActionListener l)
Removes a previously added ActionListener.

See Also:
addActionListener

fireActionEvent

protected void fireActionEvent(PageState state)
Fires an ActionEvent, which causes all registered ActionListeners to be run. The source of the event is the TabbedPane.

Parameters:
state - the current page state
See Also:
respond

respond

public void respond(PageState state)
Responds to the incoming request. Fires the ActionEvent.

Specified by:
respond in interface Component
Overrides:
respond in class SimpleComponent
Parameters:
state - the current page state

generateURL

protected void generateURL(PageState state,
                           Element parent)
Generates the URL for a link and sets it as the "href" attribute of the parent.

Specified by:
generateURL in class BaseLink
Parameters:
state - the current page state
parent - the parent element

setControlEvent

public void setControlEvent(PageState ps)
Sets the page state's control event. Should be overridden by child classes. By default, the link receives no control events whatsoever.

Parameters:
ps - the current page state


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