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, IDirectEvent, Component, IRender
Direct Known Subclasses:
AbstractFormWidget, AbstractPostfield, Button, Checkbox, DatePicker, ForBean, Hidden, IfBean, LinkSubmit, ListEdit, MultiplePropertySelection, PropertySelection, Radio, RadioGroup, Select, Submit, Suggest, 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

Field Summary
 
Fields inherited from class org.apache.tapestry.AbstractComponent
_body, _bodyCount
 
Constructor Summary
AbstractFormComponent()
           
 
Method Summary
protected  void generateClientId()
          
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, or if the containing Form is not currently rendering.
abstract  String getIdParameter()
          Should be connected to a parameter named "id" (annotations would be helpful here!).
abstract  String getName()
          Returns the name of the component, which is automatically generated during renderring.
protected  boolean getRenderBodyOnRewind()
          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.
 boolean isRequired()
          Returns false.
 String peekClientId()
          Used internally to "peek" at what the next generated client id will be for this component when it renders.
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)
          Invoked from renderComponent(IMarkupWriter, IRequestCycle) to render the component.
protected abstract  void rewindFormComponent(IMarkupWriter writer, IRequestCycle cycle)
          Invoked from renderComponent(IMarkupWriter, IRequestCycle) to rewind the component.
abstract  void setForm(IForm form)
           
protected  void setName(IForm form)
           
abstract  void setName(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, equals, finishLoad, finishLoad, 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, 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.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, getEventInvoker, getExtendedId, getId, getIdPath, getListeners, getMessages, getNamespace, getPage, getSpecification, getSpecifiedId, getTemplateTagName, isRendering, 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

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, or if the containing Form is not currently rendering.

Specified by:
getForm in interface IFormComponent

setForm

public abstract void setForm(IForm form)

getName

public abstract 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 ForBean, 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(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 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.


renderComponent

protected void renderComponent(IMarkupWriter writer,
                               IRequestCycle cycle)
Invoked by AbstractComponent.render(IMarkupWriter, IRequestCycle) to actually render the component (with any parameter values already set). This implementation checks the rewinding state of the IForm that contains the component and forwards processing to either renderFormComponent(IMarkupWriter, IRequestCycle) or rewindFormComponent(IMarkupWriter, IRequestCycle). Those two are the methods that subclasses should implement.

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

getRenderBodyOnRewind

protected boolean getRenderBodyOnRewind()
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)

generateClientId

protected void generateClientId()

Overrides:
generateClientId in class AbstractComponent

peekClientId

public String peekClientId()
Used internally to "peek" at what the next generated client id will be for this component when it renders. Similar to the logic found in IRequestCycle.peekUniqueId(String).

Specified by:
peekClientId in interface IComponent
Overrides:
peekClientId in class AbstractComponent
Returns:
The next possible client ID for this component.

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)
Invoked from renderComponent(IMarkupWriter, IRequestCycle) to render the component.

Parameters:
writer -
cycle -

rewindFormComponent

protected abstract void rewindFormComponent(IMarkupWriter writer,
                                            IRequestCycle cycle)
Invoked from renderComponent(IMarkupWriter, IRequestCycle) to rewind the component. If the component is disabled this will not be invoked.

Parameters:
writer -
cycle -


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