org.apache.tapestry.form
Class AbstractFormComponent

java.lang.Object
  extended by org.apache.hivemind.impl.BaseLocatable
      extended by org.apache.tapestry.AbstractComponent
          extended by org.apache.tapestry.form.AbstractFormComponent
All Implemented Interfaces:
org.apache.hivemind.Locatable, org.apache.hivemind.LocationHolder, IFormComponent, IComponent, IRender
Direct Known Subclasses:
AbstractPostfield, Button, Checkbox, DatePicker, ForBean, Hidden, IfBean, LinkSubmit, ListEdit, PropertySelection, RadioGroup, Select, Submit, TextArea, TextField, Upload, ValidField

public abstract class AbstractFormComponent
extends AbstractComponent
implements IFormComponent

A base class for building components that correspond to HTML form elements. All such components must be wrapped (directly or indirectly) by a Form component.

Since:
1.0.3
Author:
Howard Lewis Ship, Paul Ferraro

Constructor Summary
AbstractFormComponent()
           
 
Method Summary
protected  boolean getAlwaysRenderBodyOnRewind()
          A small number of components should always render their body on rewind (even if the component is itself disabled) and should override this method to return true.
protected  boolean getCanTakeFocus()
          Returns true if the corresponding field, on the client side, can accept user focus (i.e., implements the focus() method).
abstract  IForm getForm()
          Returns the IForm which contains the component, or null if the component is not contained by a form, of if the containing Form is not currently renderring.
abstract  java.lang.String getIdParameter()
          Should be connected to a parameter named "id" (annotations would be helpful here!).
abstract  java.lang.String getName()
          Returns the name of the component, which is automatically generated during renderring.
 boolean isRequired()
          Returns false.
protected  void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
          Invoked by AbstractComponent.render(IMarkupWriter, IRequestCycle)to actually render the component (with any parameter values already set).
protected  void renderDelegateAttributes(IMarkupWriter writer, IRequestCycle cycle)
           
protected  void renderDelegatePrefix(IMarkupWriter writer, IRequestCycle cycle)
           
protected  void renderDelegateSuffix(IMarkupWriter writer, IRequestCycle cycle)
           
protected abstract  void renderFormComponent(IMarkupWriter writer, IRequestCycle cycle)
           
protected  void renderIdAttribute(IMarkupWriter writer, IRequestCycle cycle)
          Invoked from renderFormComponent(IMarkupWriter, IRequestCycle) (that is, an implementation in a subclass), to obtain an id and render an id attribute.
protected abstract  void rewindFormComponent(IMarkupWriter writer, IRequestCycle cycle)
           
abstract  void setClientId(java.lang.String id)
          Stores the actual id allocated (or null if the component doesn't support this).
abstract  void setForm(IForm form)
           
protected  void setName(IForm form)
           
abstract  void setName(java.lang.String name)
          Invoked by FormBehavior.getElementId(IFormComponent) when a name is created for a form component.
 
Methods inherited from class org.apache.tapestry.AbstractComponent
addAsset, addBody, addComponent, checkActiveLock, cleanupAfterRender, 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, prepareForRender, 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.form.IFormComponent
getClientId, getDisplayName, isDisabled
 
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
 

Constructor Detail

AbstractFormComponent

public AbstractFormComponent()
Method Detail

getForm

public abstract IForm getForm()
Description copied from interface: IFormComponent
Returns the IForm which contains the component, or null if the component is not contained by a form, of if the containing Form is not currently renderring.

Specified by:
getForm in interface IFormComponent

setForm

public abstract void setForm(IForm form)

getName

public abstract java.lang.String getName()
Description copied from interface: IFormComponent
Returns the name of the component, which is automatically generated during renderring.

This value is set inside the component's render method and is not cleared. If the component is inside a Foreach, the value returned is the most recent name generated for the component.

This property is made available to facilitate writing JavaScript that allows components (in the client web browser) to interact.

In practice, a Script component works with the Body component to get the JavaScript code inserted and referenced.

Specified by:
getName in interface IFormComponent

setName

public abstract void setName(java.lang.String name)
Description copied from interface: IFormComponent
Invoked by FormBehavior.getElementId(IFormComponent) when a name is created for a form component.

Specified by:
setName in interface IFormComponent
See Also:
FormBehavior.getElementId(IFormComponent)

getCanTakeFocus

protected boolean getCanTakeFocus()
Returns true if the corresponding field, on the client side, can accept user focus (i.e., implements the focus() method). Most components can take focus (if not disabled), but a few (Hidden) override this method to always return false.


getIdParameter

public abstract java.lang.String getIdParameter()
Should be connected to a parameter named "id" (annotations would be helpful here!). For components w/o such a parameter, this will simply return null.


setClientId

public abstract void setClientId(java.lang.String id)
Stores the actual id allocated (or null if the component doesn't support this).


renderIdAttribute

protected void renderIdAttribute(IMarkupWriter writer,
                                 IRequestCycle cycle)
Invoked from renderFormComponent(IMarkupWriter, IRequestCycle) (that is, an implementation in a subclass), to obtain an id and render an id attribute. Reads getIdParameter().


renderComponent

protected void renderComponent(IMarkupWriter writer,
                               IRequestCycle cycle)
Description copied from class: AbstractComponent
Invoked by AbstractComponent.render(IMarkupWriter, IRequestCycle)to actually render the component (with any parameter values already set). This is the method that subclasses must implement.

Specified by:
renderComponent in class AbstractComponent
See Also:
AbstractComponent.renderComponent(org.apache.tapestry.IMarkupWriter, org.apache.tapestry.IRequestCycle)

getAlwaysRenderBodyOnRewind

protected boolean getAlwaysRenderBodyOnRewind()
A small number of components should always render their body on rewind (even if the component is itself disabled) and should override this method to return true. Components that explicitly render their body inside rewindFormComponent(IMarkupWriter, IRequestCycle) should leave this method returning false. Remember that if the component is disabled then rewindFormComponent(IMarkupWriter, IRequestCycle) won't be invoked.

Returns:
false; override this method to change.

renderDelegatePrefix

protected void renderDelegatePrefix(IMarkupWriter writer,
                                    IRequestCycle cycle)

renderDelegateAttributes

protected void renderDelegateAttributes(IMarkupWriter writer,
                                        IRequestCycle cycle)

renderDelegateSuffix

protected void renderDelegateSuffix(IMarkupWriter writer,
                                    IRequestCycle cycle)

setName

protected void setName(IForm form)

isRequired

public boolean isRequired()
Returns false. Subclasses that might be required must override this method. Typically, this involves checking against the component's validators.

Specified by:
isRequired in interface IFormComponent
Since:
4.0

renderFormComponent

protected abstract void renderFormComponent(IMarkupWriter writer,
                                            IRequestCycle cycle)

rewindFormComponent

protected abstract void rewindFormComponent(IMarkupWriter writer,
                                            IRequestCycle cycle)