org.apache.tapestry.link
Class AbstractLinkComponent

java.lang.Object
  extended by org.apache.tapestry.spec.BaseLocatable
      extended by org.apache.tapestry.AbstractComponent
          extended by org.apache.tapestry.link.AbstractLinkComponent
All Implemented Interfaces:
ILinkComponent, IComponent, ILocatable, ILocationHolder, IRender
Direct Known Subclasses:
ActionLink, DirectLink, ExternalLink, GenericLink, PageLink, ServiceLink

public abstract class AbstractLinkComponent
extends AbstractComponent
implements ILinkComponent

Base class for implementations of ILinkComponent. Includes a disabled attribute (that should be bound to a disabled parameter), an anchor attribute, and a renderer attribute (that should be bound to a renderer parameter). A default, shared instance of DefaultLinkRenderer is used when no specific renderer is provided.

Version:
$Id: AbstractLinkComponent.java 243791 2004-02-19 17:38:13Z hlship $
Author:
Howard Lewis Ship

Constructor Summary
AbstractLinkComponent()
           
 
Method Summary
 void addEventHandler(LinkEventType eventType, String functionName)
          Adds an event handler (typically, from a wrapped component such as a Rollover).
protected  void cleanupAfterRender(IRequestCycle cycle)
          Invoked by AbstractComponent.render(IMarkupWriter, IRequestCycle) after the component renders, to clear any parameters back to null (or 0, or false, or whatever the correct default is).
protected  void finishLoad()
          Sets the renderer parameter property to its default value DefaultLinkRenderer.SHARED_INSTANCE.
abstract  String getAnchor()
          Returns the anchor defined for this link, or null for no anchor.
 ILink getLink(IRequestCycle cycle)
          Invoked by the ILinkRenderer (if the link is not disabled) to provide a EngineServiceLink that the renderer can convert into a URL.
protected  ILink getLink(IRequestCycle cycle, String serviceName, Object[] serviceParameters)
          Utility method for subclasses; Gets the named service from the engine and invokes IEngineService.getLink(IRequestCycle, org.apache.tapestry.IComponent, Object[]) on it.
abstract  ILinkRenderer getRenderer()
           
abstract  boolean isDisabled()
          Returns whether this service link component is enabled or disabled.
 void renderAdditionalAttributes(IMarkupWriter writer, IRequestCycle cycle)
          Invoked (by the ILinkRenderer) to make the link render any additional attributes.
protected  void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
          Renders the link by delegating to an instance of ILinkRenderer.
abstract  void setRenderer(ILinkRenderer renderer)
           
protected  String writeEventHandler(IMarkupWriter writer, Body body, String name, String attributeName, Object value)
           
protected  void writeEventHandlers(IMarkupWriter writer, IRequestCycle cycle)
           
 
Methods inherited from class org.apache.tapestry.AbstractComponent
addAsset, addBody, addComponent, finishLoad, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, format, format, format, format, formatString, formatString, formatString, formatString, generateAttributes, getAsset, getAssets, getBeans, getBinding, getBindingNames, getBindings, getBody, getBodyCount, getChangeObserver, getComponent, getComponents, getContainer, getExtendedId, getId, getIdPath, getListeners, getMessage, getMessages, getNamespace, getPage, getProperty, getSpecification, getString, pageEndRender, prepareForRender, render, renderBody, renderInformalParameters, setBinding, setContainer, setId, setNamespace, setPage, setProperty, setSpecification, toString
 
Methods inherited from class org.apache.tapestry.spec.BaseLocatable
getLocation, setLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.tapestry.IComponent
addAsset, addBody, addComponent, finishLoad, getAsset, getAssets, getBinding, getBindingNames, getBindings, getComponent, getComponents, getContainer, getExtendedId, getId, getIdPath, getMessage, getMessages, getNamespace, getPage, getProperty, getSpecification, getString, renderBody, setBinding, setContainer, setId, setNamespace, setPage, setProperty, setSpecification
 
Methods inherited from interface org.apache.tapestry.IRender
render
 
Methods inherited from interface org.apache.tapestry.ILocationHolder
setLocation
 
Methods inherited from interface org.apache.tapestry.ILocatable
getLocation
 

Constructor Detail

AbstractLinkComponent

public AbstractLinkComponent()
Method Detail

isDisabled

public abstract boolean isDisabled()
Description copied from interface: ILinkComponent
Returns whether this service link component is enabled or disabled.

Specified by:
isDisabled in interface ILinkComponent

addEventHandler

public void addEventHandler(LinkEventType eventType,
                            String functionName)
Adds an event handler (typically, from a wrapped component such as a Rollover).

Specified by:
addEventHandler in interface ILinkComponent

renderComponent

protected void renderComponent(IMarkupWriter writer,
                               IRequestCycle cycle)
Renders the link by delegating to an instance of ILinkRenderer.

Specified by:
renderComponent in class AbstractComponent

cleanupAfterRender

protected void cleanupAfterRender(IRequestCycle cycle)
Description copied from class: AbstractComponent
Invoked by AbstractComponent.render(IMarkupWriter, IRequestCycle) after the component renders, to clear any parameters back to null (or 0, or false, or whatever the correct default is). Primarily, this is used to ensure that the component doesn't hold onto any objects that could otherwise be garbage collected.

Subclasses may override this implementation, but must also invoke it.

Overrides:
cleanupAfterRender in class AbstractComponent

writeEventHandlers

protected void writeEventHandlers(IMarkupWriter writer,
                                  IRequestCycle cycle)

writeEventHandler

protected String writeEventHandler(IMarkupWriter writer,
                                   Body body,
                                   String name,
                                   String attributeName,
                                   Object value)

getRenderer

public abstract ILinkRenderer getRenderer()
Since:
3.0

setRenderer

public abstract void setRenderer(ILinkRenderer renderer)

renderAdditionalAttributes

public void renderAdditionalAttributes(IMarkupWriter writer,
                                       IRequestCycle cycle)
Description copied from interface: ILinkComponent
Invoked (by the ILinkRenderer) to make the link render any additional attributes. These are informal parameters, plus any attributes related to events. This is only invoked for non-disabled links.

Specified by:
renderAdditionalAttributes in interface ILinkComponent

getLink

protected ILink getLink(IRequestCycle cycle,
                        String serviceName,
                        Object[] serviceParameters)
Utility method for subclasses; Gets the named service from the engine and invokes IEngineService.getLink(IRequestCycle, org.apache.tapestry.IComponent, Object[]) on it.

Since:
3.0

getAnchor

public abstract String getAnchor()
Description copied from interface: ILinkComponent
Returns the anchor defined for this link, or null for no anchor.

Specified by:
getAnchor in interface ILinkComponent

getLink

public ILink getLink(IRequestCycle cycle)
Description copied from interface: ILinkComponent
Invoked by the ILinkRenderer (if the link is not disabled) to provide a EngineServiceLink that the renderer can convert into a URL.

Specified by:
getLink in interface ILinkComponent

finishLoad

protected void finishLoad()
Sets the renderer parameter property to its default value DefaultLinkRenderer.SHARED_INSTANCE.

Overrides:
finishLoad in class AbstractComponent
Since:
3.0