org.apache.tapestry.link
Class AbstractLinkComponent

java.lang.Object
  extended by org.apache.hivemind.impl.BaseLocatable
      extended by org.apache.tapestry.AbstractComponent
          extended by org.apache.tapestry.link.AbstractLinkComponent
All Implemented Interfaces:
org.apache.hivemind.Locatable, org.apache.hivemind.LocationHolder, ILinkComponent, IComponent, IDirectEvent, Component, IRender
Direct Known Subclasses:
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.

Author:
Howard Lewis Ship

Field Summary
 
Fields inherited from class org.apache.tapestry.AbstractComponent
_body, _bodyCount
 
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.
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.
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, PageRenderSupport pageRenderSupport, String name, String attributeName, Object value)
           
protected  void writeEventHandlers(IMarkupWriter writer, IRequestCycle cycle)
           
 
Methods inherited from class org.apache.tapestry.AbstractComponent
addAsset, addBody, addComponent, checkActiveLock, enterActiveState, equals, finishLoad, generateClientId, getAsset, getAssets, getBeans, getBinding, getBindingNames, getBindings, getBody, getBodyCount, getBoundId, getClientId, getComponent, getComponents, getContainedComponent, getContainedRenderers, getContainer, getEventInvoker, getExtendedId, getId, getIdPath, getInnerRenderers, getListeners, getMessages, getNamespace, getPage, getRenderWorker, getSpecification, getSpecifiedId, getTemplateTagName, hasEvents, hashCode, isInActiveState, isParameterBound, isRendering, isStateful, pageEndRender, peekClientId, prepareForRender, render, renderBody, renderIdAttribute, renderInformalParameters, setBinding, setClientId, setContainedComponent, setContainer, setHasEvents, setId, setNamespace, setPage, setTemplateTagName, toString, triggerEvent
 
Methods inherited from class org.apache.hivemind.impl.BaseLocatable
getLocation, setLocation
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.tapestry.components.ILinkComponent
getPort, getScheme, getTarget
 
Methods inherited from interface org.apache.tapestry.IComponent
addAsset, addBody, addComponent, enterActiveState, finishLoad, getAsset, getAssets, getBeans, getBinding, getBindingNames, getBindings, getClientId, getComponent, getComponents, getContainedComponent, getContainer, getEventInvoker, getExtendedId, getId, getIdPath, getListeners, getMessages, getNamespace, getPage, getSpecification, getSpecifiedId, getTemplateTagName, isRendering, peekClientId, renderBody, setBinding, setClientId, setContainedComponent, setContainer, setId, setNamespace, setPage, setTemplateTagName
 
Methods inherited from interface org.apache.tapestry.IRender
render
 
Methods inherited from interface org.apache.hivemind.LocationHolder
setLocation
 
Methods inherited from interface org.apache.hivemind.Locatable
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
Returns:
True if disabled, false otherwise.

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
Parameters:
eventType - The type of event to add.
functionName - The name of the client side javascript function to generate.

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.

Overrides:
cleanupAfterRender in class AbstractComponent

writeEventHandlers

protected void writeEventHandlers(IMarkupWriter writer,
                                  IRequestCycle cycle)

writeEventHandler

protected String writeEventHandler(IMarkupWriter writer,
                                   PageRenderSupport pageRenderSupport,
                                   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
Parameters:
writer - Markup writer to write content to.
cycle - The current request.

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
Returns:
The #anchorid portion of the url to be generated - if any.

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
Parameters:
cycle - The current request.
Returns:
A ILink instance representing the link information for this component.

finishLoad

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

Overrides:
finishLoad in class AbstractComponent
Since:
3.0


Copyright © 2006-2008 Apache Software Foundation. All Rights Reserved.