net.sf.tacos.ajax.components
Class AjaxForm

java.lang.Object
  extended by org.apache.hivemind.impl.BaseLocatable
      extended by org.apache.tapestry.AbstractComponent
          extended by net.sf.tacos.ajax.components.AjaxForm
All Implemented Interfaces:
AjaxInvocation, Locatable, LocationHolder, org.apache.tapestry.FormBehavior, org.apache.tapestry.IAction, org.apache.tapestry.IComponent, org.apache.tapestry.IDirect, org.apache.tapestry.IForm, org.apache.tapestry.IRender

public abstract class AjaxForm
extends org.apache.tapestry.AbstractComponent
implements org.apache.tapestry.IForm, org.apache.tapestry.IDirect, AjaxInvocation

Overrides default Form behaviour.

Author:
jkuhnert

Nested Class Summary
protected  class AjaxForm.RenderInformalParameters
          Handles rendering informal parameters for form in a runnable.
 
Field Summary
protected  AjaxFormSupport formSupport
          Form support.
protected  String name
          Unique form name.
protected  org.apache.tapestry.IRender renderInformalParameters
          Renderer
 
Fields inherited from interface org.apache.tapestry.IForm
ATTRIBUTE_NAME
 
Constructor Summary
AjaxForm()
           
 
Method Summary
 void addDeferredRunnable(Runnable runnable)
           
 void addEventHandler(org.apache.tapestry.form.FormEventType type, String functionName)
          Adds an additional event handler.
 void addHiddenValue(String name, String value)
           
 void addHiddenValue(String name, String id, String value)
           
protected  void cleanupAfterRender(org.apache.tapestry.IRequestCycle cycle)
          
protected  String constructFormNameForActionService(String actionId)
          Construct a form name for use with the action service.
 Map constructScriptParameter(org.apache.tapestry.IRequestCycle cycle)
          Construct the parameter used by script.
static org.apache.tapestry.IForm get(org.apache.tapestry.IRequestCycle cycle)
          Deprecated. Use TapestryUtils.getForm(IRequestCycle, IComponent) instead.
abstract  org.apache.tapestry.engine.IEngineService getActionService()
          Injected.
 org.apache.tapestry.engine.ILink getAjaxLink()
          Generates ajax link for form submission via javascript
abstract  AjaxWebRequest getAjaxRequest()
          Injected request.
abstract  org.apache.tapestry.IActionListener getCancel()
          cancel parameter, may be null
abstract  org.apache.tapestry.valid.IValidationDelegate getDelegate()
          delegate parameter, which has a default (starting in release 4.0).
abstract  org.apache.tapestry.engine.IEngineService getDirectService()
          Injected.
 String getElementId(org.apache.tapestry.form.IFormComponent component)
          Constructs a unique identifier (within the Form).
 String getElementId(org.apache.tapestry.form.IFormComponent component, String baseId)
          Constructs a unique identifier from the base id.
 String getEncodingType()
          Should return null if current form is not a AjaxForm.
abstract  org.apache.tapestry.IActionListener getListener()
          listener parameter, may be null
abstract  org.apache.tapestry.listener.ListenerInvoker getListenerInvoker()
          Injected
abstract  String getMethod()
          method parameter
 String getName()
          Returns the name generated for the form.
abstract  Integer getPort()
          port parameter, may be null
abstract  org.apache.tapestry.IActionListener getRefresh()
          refresh parameter, may be null
 boolean getRequiresSession()
          Returns true if the stateful parameter is bound to a true value.
abstract  org.apache.tapestry.web.WebResponse getResponse()
          Injected
abstract  String getScheme()
          scheme parameter, may be null
abstract  org.apache.tapestry.IScript getScript()
          Injected tacos js.
abstract  org.apache.tapestry.IActionListener getSuccess()
          success parameter, may be null
abstract  boolean isDirect()
          Returns true if this Form is configured to use the direct service.
 boolean isRewinding()
          Indicates to any wrapped form components that they should respond to the form submission.
abstract  boolean isStateful()
          stateful parameter
protected  AjaxFormSupport newFormSupport(org.apache.tapestry.IMarkupWriter writer, org.apache.tapestry.IRequestCycle cycle)
          Returns a new instance of AjaxFormSupport.
protected  void prepareForRender(org.apache.tapestry.IRequestCycle cycle)
           
 void prerenderField(org.apache.tapestry.IMarkupWriter writer, org.apache.tapestry.IComponent field, Location location)
          
 void registerForFocus(org.apache.tapestry.form.IFormComponent field, int priority)
          
protected  void renderComponent(org.apache.tapestry.IMarkupWriter writer, org.apache.tapestry.IRequestCycle cycle)
          
protected  void renderComponentDelegate(org.apache.tapestry.IMarkupWriter writer, org.apache.tapestry.IRequestCycle cycle)
          Renders delegate components.
 void rewind(org.apache.tapestry.IMarkupWriter writer, org.apache.tapestry.IRequestCycle cycle)
          Overriden so that AjaxWebRequest will be put back as an attribute on the IRequestCycle after rewind.
 void setEncodingType(String encodingType)
          
 void trigger(org.apache.tapestry.IRequestCycle cycle)
          Method invoked by the direct service.
 boolean wasPrerendered(org.apache.tapestry.IMarkupWriter writer, org.apache.tapestry.IComponent field)
          
 
Methods inherited from class org.apache.tapestry.AbstractComponent
addAsset, addBody, addComponent, checkActiveLock, enterActiveState, finishLoad, finishLoad, format, format, format, format, getAsset, getAssets, getBeans, getBinding, getBindingNames, getBindings, getBody, getBodyCount, getComponent, getComponents, getContainedComponent, getContainer, getExtendedId, getId, getIdPath, getListeners, getMessage, getMessages, getNamespace, getPage, getProperty, getSpecification, isInActiveState, isParameterBound, isRendering, pageEndRender, render, renderBody, renderInformalParameters, setBinding, setContainedComponent, setContainer, setId, setNamespace, setPage, setProperty, toString
 
Methods inherited from class org.apache.hivemind.impl.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.IForm
getFocus, isClientValidationEnabled
 
Methods inherited from interface org.apache.tapestry.IComponent
addAsset, addBody, addComponent, enterActiveState, finishLoad, getAsset, getAssets, getBeans, getBinding, getBindingNames, getBindings, getComponent, getComponents, getContainedComponent, getContainer, getExtendedId, getId, getIdPath, getListeners, getMessage, getMessages, getNamespace, getPage, getProperty, getSpecification, isRendering, renderBody, setBinding, setContainedComponent, setContainer, setId, setNamespace, setPage, setProperty
 
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
 
Methods inherited from interface net.sf.tacos.ajax.AjaxInvocation
getAjaxEngine, getBackLink, getEffects, getForwardLink, getPopup, getPreEffects, getStatusElement, getUpdateComponents, getUpdateObject
 

Field Detail

name

protected String name
Unique form name.


formSupport

protected AjaxFormSupport formSupport
Form support.


renderInformalParameters

protected org.apache.tapestry.IRender renderInformalParameters
Renderer

Constructor Detail

AjaxForm

public AjaxForm()
Method Detail

getScript

public abstract org.apache.tapestry.IScript getScript()
Injected tacos js.


getAjaxRequest

public abstract AjaxWebRequest getAjaxRequest()
Injected request.


renderComponent

protected void renderComponent(org.apache.tapestry.IMarkupWriter writer,
                               org.apache.tapestry.IRequestCycle cycle)

Specified by:
renderComponent in class org.apache.tapestry.AbstractComponent

constructScriptParameter

public Map constructScriptParameter(org.apache.tapestry.IRequestCycle cycle)
Construct the parameter used by script.

Parameters:
cycle -
Returns:
script parameter map

getAjaxLink

public org.apache.tapestry.engine.ILink getAjaxLink()
Generates ajax link for form submission via javascript

Specified by:
getAjaxLink in interface AjaxInvocation
Returns:
ILink to be used in async io javascript calls

rewind

public void rewind(org.apache.tapestry.IMarkupWriter writer,
                   org.apache.tapestry.IRequestCycle cycle)
Overriden so that AjaxWebRequest will be put back as an attribute on the IRequestCycle after rewind.

Specified by:
rewind in interface org.apache.tapestry.IForm

get

public static org.apache.tapestry.IForm get(org.apache.tapestry.IRequestCycle cycle)
Deprecated. Use TapestryUtils.getForm(IRequestCycle, IComponent) instead.

Returns the currently active IForm, or null if no form is active. This is a convienience method, the result will be null, or an instance of IForm, but not necessarily a Form.


isRewinding

public boolean isRewinding()
Indicates to any wrapped form components that they should respond to the form submission.

Specified by:
isRewinding in interface org.apache.tapestry.FormBehavior

getDirectService

public abstract org.apache.tapestry.engine.IEngineService getDirectService()
Injected.

Since:
4.0

getActionService

public abstract org.apache.tapestry.engine.IEngineService getActionService()
Injected.

Since:
4.0

isDirect

public abstract boolean isDirect()
Returns true if this Form is configured to use the direct service.

This is derived from the direct parameter, and defaults to true if not bound.

Since:
1.0.2

getRequiresSession

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

Specified by:
getRequiresSession in interface org.apache.tapestry.IAction
Since:
1.0.1

getElementId

public String getElementId(org.apache.tapestry.form.IFormComponent component)
Constructs a unique identifier (within the Form). The identifier consists of the component's id, with an index number added to ensure uniqueness.

Simply invokes getElementId(org.apache.tapestry.form.IFormComponent, java.lang.String)with the component's id.

Specified by:
getElementId in interface org.apache.tapestry.FormBehavior
Since:
1.0.2

getElementId

public String getElementId(org.apache.tapestry.form.IFormComponent component,
                           String baseId)
Constructs a unique identifier from the base id. If possible, the id is used as-is. Otherwise, a unique identifier is appended to the id.

This method is provided simply so that some components (ImageSubmit) have more specific control over their names.

Specified by:
getElementId in interface org.apache.tapestry.FormBehavior
Since:
1.0.3

getName

public String getName()
Returns the name generated for the form. This is used to faciliate components that write JavaScript and need to access the form or its contents.

This value is generated when the form renders, and is not cleared. If the Form is inside a Foreach, this will be the most recently generated name for the Form.

This property is exposed so that sophisticated applications can write JavaScript handlers for the form and components within the form.

Specified by:
getName in interface org.apache.tapestry.IForm
See Also:
AbstractFormComponent.getName()

prepareForRender

protected void prepareForRender(org.apache.tapestry.IRequestCycle cycle)
Overrides:
prepareForRender in class org.apache.tapestry.AbstractComponent
Since:
3.0 *

cleanupAfterRender

protected void cleanupAfterRender(org.apache.tapestry.IRequestCycle cycle)

Overrides:
cleanupAfterRender in class org.apache.tapestry.AbstractComponent

renderComponentDelegate

protected void renderComponentDelegate(org.apache.tapestry.IMarkupWriter writer,
                                       org.apache.tapestry.IRequestCycle cycle)
Renders delegate components.

Parameters:
writer -
cycle -

constructFormNameForActionService

protected String constructFormNameForActionService(String actionId)
Construct a form name for use with the action service. This implementation returns "Form" appended with the actionId.

Since:
4.0

newFormSupport

protected AjaxFormSupport newFormSupport(org.apache.tapestry.IMarkupWriter writer,
                                         org.apache.tapestry.IRequestCycle cycle)
Returns a new instance of AjaxFormSupport.


addEventHandler

public void addEventHandler(org.apache.tapestry.form.FormEventType type,
                            String functionName)
Adds an additional event handler.

Specified by:
addEventHandler in interface org.apache.tapestry.FormBehavior
Since:
1.0.2

trigger

public void trigger(org.apache.tapestry.IRequestCycle cycle)
Method invoked by the direct service.

Specified by:
trigger in interface org.apache.tapestry.IDirect
Since:
1.0.2

getResponse

public abstract org.apache.tapestry.web.WebResponse getResponse()
Injected


getDelegate

public abstract org.apache.tapestry.valid.IValidationDelegate getDelegate()
delegate parameter, which has a default (starting in release 4.0).

Specified by:
getDelegate in interface org.apache.tapestry.IForm

getListener

public abstract org.apache.tapestry.IActionListener getListener()
listener parameter, may be null


getSuccess

public abstract org.apache.tapestry.IActionListener getSuccess()
success parameter, may be null


getCancel

public abstract org.apache.tapestry.IActionListener getCancel()
cancel parameter, may be null


getRefresh

public abstract org.apache.tapestry.IActionListener getRefresh()
refresh parameter, may be null


getMethod

public abstract String getMethod()
method parameter


isStateful

public abstract boolean isStateful()
stateful parameter

Specified by:
isStateful in interface org.apache.tapestry.IDirect

getScheme

public abstract String getScheme()
scheme parameter, may be null


getPort

public abstract Integer getPort()
port parameter, may be null


setEncodingType

public void setEncodingType(String encodingType)

Specified by:
setEncodingType in interface org.apache.tapestry.FormBehavior

addHiddenValue

public void addHiddenValue(String name,
                           String value)
Specified by:
addHiddenValue in interface org.apache.tapestry.FormBehavior
Since:
3.0

addHiddenValue

public void addHiddenValue(String name,
                           String id,
                           String value)
Specified by:
addHiddenValue in interface org.apache.tapestry.FormBehavior
Since:
3.0

prerenderField

public void prerenderField(org.apache.tapestry.IMarkupWriter writer,
                           org.apache.tapestry.IComponent field,
                           Location location)

Specified by:
prerenderField in interface org.apache.tapestry.FormBehavior

wasPrerendered

public boolean wasPrerendered(org.apache.tapestry.IMarkupWriter writer,
                              org.apache.tapestry.IComponent field)

Specified by:
wasPrerendered in interface org.apache.tapestry.FormBehavior

addDeferredRunnable

public void addDeferredRunnable(Runnable runnable)
Specified by:
addDeferredRunnable in interface org.apache.tapestry.FormBehavior
Since:
4.0

getListenerInvoker

public abstract org.apache.tapestry.listener.ListenerInvoker getListenerInvoker()
Injected

Since:
4.0

registerForFocus

public void registerForFocus(org.apache.tapestry.form.IFormComponent field,
                             int priority)

Specified by:
registerForFocus in interface org.apache.tapestry.FormBehavior

getEncodingType

public String getEncodingType()
Description copied from interface: AjaxInvocation
Should return null if current form is not a AjaxForm.

Specified by:
getEncodingType in interface AjaxInvocation
Returns:
encoding type