org.apache.tapestry.valid
Class ValidField

java.lang.Object
  extended by org.apache.tapestry.spec.BaseLocatable
      extended by org.apache.tapestry.AbstractComponent
          extended by org.apache.tapestry.form.AbstractFormComponent
              extended by org.apache.tapestry.form.AbstractTextField
                  extended by org.apache.tapestry.valid.ValidField
All Implemented Interfaces:
IFormComponent, IComponent, ILocatable, ILocationHolder, IRender
Direct Known Subclasses:
DateField, NumericField, ValidatingTextField

public abstract class ValidField
extends AbstractTextField
implements IFormComponent

A Form component that creates a text field that allows for validation of user input and conversion between string and object values. [Component Reference]

A ValidatingTextField uses an IValidationDelegate to track errors and an IValidator to convert between strings and objects (as well as perform validations). The validation delegate is shared by all validating text fields in a form, the validator may be shared my multiple elements as desired.

Version:
$Id: ValidField.java 243791 2004-02-19 17:38:13Z hlship $
Author:
Howard Lewis Ship

Constructor Summary
ValidField()
           
 
Method Summary
protected  void addSelect(IRequestCycle cycle)
          Creates JavaScript to set the cursor on the first required or error field encountered while rendering.
protected  void beforeCloseTag(IMarkupWriter writer, IRequestCycle cycle)
          Invokes IValidationDelegate.writeAttributes(IMarkupWriter,IRequestCycle, IFormComponent,IValidator).
abstract  String getDisplayName()
          Implemented in some subclasses to provide a display name (suitable for presentation to the user as a label or error message).
abstract  IValidator getValidator()
           
abstract  Object getValue()
           
protected  String readValue()
          Invoked by AbstractComponent.render(IMarkupWriter writer, IRequestCycle cycle) when rendering a response.
protected  void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
          Renders the component, which involves the delegate.
abstract  void setValue(Object value)
           
protected  void updateValue(String value)
          Invoked by AbstractComponent.render(IMarkupWriter writer, IRequestCycle cycle) when a value is obtained from the HttpServletRequest.
 
Methods inherited from class org.apache.tapestry.form.AbstractTextField
isDisabled, isHidden
 
Methods inherited from class org.apache.tapestry.form.AbstractFormComponent
getForm, getForm, getName, setForm, setName
 
Methods inherited from class org.apache.tapestry.AbstractComponent
addAsset, addBody, addComponent, cleanupAfterRender, finishLoad, finishLoad, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, fireObservedChange, format, format, format, format, formatString, formatString, formatString, formatString, generateAttributes, getAsset, getAssets, getBeans, getBinding, getBindingNames, getBindings, getBody, getBodyCount, getChangeObserver, getComponent, getComponents, getContainer, getExtendedId, getId, getIdPath, getListeners, getMessage, getMessages, getNamespace, getPage, getProperty, getSpecification, getString, pageEndRender, prepareForRender, render, renderBody, renderInformalParameters, setBinding, setContainer, setId, setNamespace, setPage, setProperty, setSpecification, toString
 
Methods inherited from class org.apache.tapestry.spec.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
getForm, getName, isDisabled, setName
 
Methods inherited from interface org.apache.tapestry.IComponent
addAsset, addBody, addComponent, finishLoad, getAsset, getAssets, getBinding, getBindingNames, getBindings, getComponent, getComponents, getContainer, getExtendedId, getId, getIdPath, getMessage, getMessages, getNamespace, getPage, getProperty, getSpecification, getString, renderBody, setBinding, setContainer, setId, setNamespace, setPage, setProperty, setSpecification
 
Methods inherited from interface org.apache.tapestry.IRender
render
 
Methods inherited from interface org.apache.tapestry.ILocationHolder
setLocation
 
Methods inherited from interface org.apache.tapestry.ILocatable
getLocation
 

Constructor Detail

ValidField

public ValidField()
Method Detail

getValue

public abstract Object getValue()

setValue

public abstract void setValue(Object value)

getDisplayName

public abstract String getDisplayName()
Description copied from class: AbstractFormComponent
Implemented in some subclasses to provide a display name (suitable for presentation to the user as a label or error message). This implementation return null.

Specified by:
getDisplayName in interface IFormComponent
Overrides:
getDisplayName in class AbstractFormComponent

renderComponent

protected void renderComponent(IMarkupWriter writer,
                               IRequestCycle cycle)
Renders the component, which involves the delegate.

During a render, the first field rendered that is either in error, or required but null gets special treatment. JavaScript is added to select that field (such that the cursor jumps right to the field when the page loads).

Overrides:
renderComponent in class AbstractTextField

beforeCloseTag

protected void beforeCloseTag(IMarkupWriter writer,
                              IRequestCycle cycle)
Invokes IValidationDelegate.writeAttributes(IMarkupWriter,IRequestCycle, IFormComponent,IValidator).

Overrides:
beforeCloseTag in class AbstractTextField

addSelect

protected void addSelect(IRequestCycle cycle)
Creates JavaScript to set the cursor on the first required or error field encountered while rendering. This only works if the text field is wrapped by a Body component (which is almost always true).


readValue

protected String readValue()
Description copied from class: AbstractTextField
Invoked by AbstractComponent.render(IMarkupWriter writer, IRequestCycle cycle) when rendering a response.

Specified by:
readValue in class AbstractTextField
Returns:
the current value for the field, as a String, or null.

updateValue

protected void updateValue(String value)
Description copied from class: AbstractTextField
Invoked by AbstractComponent.render(IMarkupWriter writer, IRequestCycle cycle) when a value is obtained from the HttpServletRequest.

Specified by:
updateValue in class AbstractTextField

getValidator

public abstract IValidator getValidator()