com.primix.tapestry.link
Class Direct

java.lang.Object
  |
  +--com.primix.tapestry.AbstractComponent
        |
        +--com.primix.tapestry.link.AbstractServiceLink
              |
              +--com.primix.tapestry.link.Direct
All Implemented Interfaces:
IComponent, IDirect, IRender, IServiceLink

public class Direct
extends AbstractServiceLink
implements IDirect

A component for creating a link using the direct service; used for actions that are not dependant on dynamic page state.
Parameter Type Read / Write Required Default Description
listener IDirectListener R yes   Specifies an object that is notified when the link is clicked.
context String[]
List (of String)
String
Object
R no   An array of Strings to be encoded into the URL. These parameters will be decoded when the link is triggered.

If the context is simply an Object, then toString() is invoked on it. It is assumed that the listener will be able to convert it back.

In a web application built onto of Enterprise JavaBeans, the context is often the primary key of some Entity bean; typically such keys are Strings or Integers (which can be freely converted from String to Integer by the listener).

disabled boolean R no true Controls whether the link is produced. If disabled, the portion of the template the link surrounds is still rendered, but not the link itself.
stateful boolean R no true If true (the default), then the component requires an active (i.e., non-new) HttpSession when triggered. Failing that, it throws a StaleLinkException. If false, then no check is necessary. The latter works well with links that encode all necessary state inside the URL itself.
scheme java.lang.String R no   If specified, then a longer URL (including scheme, server and possibly port) is generated using the specified scheme. Server is determined fromt he incoming request, and port is deterimined from the port paramter or the incoming request.
port int R no   If specified, then a longer URL (including scheme, server and port) is generated using the specified port. The server is determined from the incoming request, the scheme from the scheme paramter or the incoming request.
anchor java.lang.String R no   The name of an anchor or element to link to. The final URL will have '#' and the anchor appended to it.

Informal parameters are allowed.

Version:
$Id: Direct.java,v 1.9 2001/05/30 16:13:20 hship Exp $
Author:
Howard Ship

Fields inherited from class com.primix.tapestry.AbstractComponent
id, page, specification, wrapped, wrappedCount
 
Fields inherited from interface com.primix.tapestry.components.IServiceLink
ATTRIBUTE_NAME
 
Constructor Summary
Direct()
           
 
Method Summary
static java.lang.String[] getContext(IBinding binding)
          Converts a binding to a context (an array of Strings).
protected  java.lang.String[] getContext(IRequestCycle cycle)
          Invoked by AbstractServiceLink.render(IResponseWriter, IRequestCycle) if the component is enabled.
 IBinding getContextBinding()
           
 IBinding getListenerBinding()
           
protected  java.lang.String getServiceName(IRequestCycle cycle)
          Returns IEngineService.DIRECT_SERVICE.
 IBinding getStatefulBinding()
           
 boolean isStateful()
          Returns true if the stateful parameter is bound to a true value.
 void setContextBinding(IBinding value)
           
 void setListenerBinding(IBinding value)
           
 void setStatefulBinding(IBinding value)
           
 void trigger(IRequestCycle cycle, java.lang.String[] context)
          Invoked by the direct service to trigger the application-specific action by notifying the listener.
 
Methods inherited from class com.primix.tapestry.link.AbstractServiceLink
addEventHandler, buildURL, getAnchorBinding, getDisabledBinding, getPortBinding, getSchemeBinding, isDisabled, render, setAnchorBinding, setDisabledBinding, setPortBinding, setSchemeBinding, setup
 
Methods inherited from class com.primix.tapestry.AbstractComponent
addAsset, addComponent, addWrapped, cleanupAfterRender, cleanupComponent, finishLoad, finishLoad, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, generateAttributes, getAsset, getAssets, getBeans, getBinding, getBindingNames, getBindings, getChangeObserver, getComponent, getComponents, getContainer, getExtendedId, getId, getIdPath, getListeners, getPage, getSpecification, prepareForRender, renderWrapped, reset, setBinding, setContainer, setId, setPage, setSpecification, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.primix.tapestry.IComponent
addAsset, addComponent, addWrapped, finishLoad, getAsset, getAssets, getBinding, getBindingNames, getBindings, getComponent, getComponents, getContainer, getExtendedId, getId, getIdPath, getPage, getSpecification, renderWrapped, setBinding, setContainer, setId, setPage, setSpecification
 
Methods inherited from interface com.primix.tapestry.IRender
render
 

Constructor Detail

Direct

public Direct()
Method Detail

setContextBinding

public void setContextBinding(IBinding value)

getContextBinding

public IBinding getContextBinding()

setStatefulBinding

public void setStatefulBinding(IBinding value)

getStatefulBinding

public IBinding getStatefulBinding()

isStateful

public boolean isStateful()
Returns true if the stateful parameter is bound to a true value. If stateful is not bound, also returns the default, true.

getServiceName

protected java.lang.String getServiceName(IRequestCycle cycle)
Returns IEngineService.DIRECT_SERVICE.
Overrides:
getServiceName in class AbstractServiceLink
Following copied from class: com.primix.tapestry.link.AbstractServiceLink
See Also:
AbstractServiceLink.buildURL(IRequestCycle, String[])

getContext

protected java.lang.String[] getContext(IRequestCycle cycle)
Description copied from class: AbstractServiceLink
Invoked by AbstractServiceLink.render(IResponseWriter, IRequestCycle) if the component is enabled. The default implementation returns null; other implementations can provide appropriate parameters as needed.
Overrides:
getContext in class AbstractServiceLink

getContext

public static java.lang.String[] getContext(IBinding binding)
Converts a binding to a context (an array of Strings). This is used by the Direct and Service components.

trigger

public void trigger(IRequestCycle cycle,
                    java.lang.String[] context)
             throws RequestCycleException
Invoked by the direct service to trigger the application-specific action by notifying the listener.
Specified by:
trigger in interface IDirect
Throws:
StaleSessionException - if the component is stateful, and the session is new.

getListenerBinding

public IBinding getListenerBinding()

setListenerBinding

public void setListenerBinding(IBinding value)