org.apache.tapestry.valid
Class ValidField
java.lang.Object
org.apache.hivemind.impl.BaseLocatable
org.apache.tapestry.AbstractComponent
org.apache.tapestry.form.AbstractFormComponent
org.apache.tapestry.form.AbstractTextField
org.apache.tapestry.valid.ValidField
- All Implemented Interfaces:
- IComponent, IFormComponent, IRender, org.apache.hivemind.Locatable, org.apache.hivemind.LocationHolder
- 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.
- Author:
- Howard Lewis Ship
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 java.lang.String |
getDisplayName()
May be implemented to return a user-presentable, localized name for the component,
which is used in labels or error messages. |
abstract IValidator |
getValidator()
|
abstract java.lang.Object |
getValue()
|
protected java.lang.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(java.lang.Object value)
|
protected void |
updateValue(java.lang.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.AbstractComponent |
addAsset, addBody, addComponent, checkActiveLock, cleanupAfterRender, enterActiveState, finishLoad, finishLoad, getAsset, getAssets, getBeans, getBinding, getBindingNames, getBindings, getBody, getBodyCount, getComponent, getComponents, getContainer, getExtendedId, getId, getIdPath, getListeners, getMessages, getNamespace, getPage, getProperty, getSpecification, isInActiveState, isParameterBound, isRendering, pageEndRender, prepareForRender, render, renderBody, renderInformalParameters, setBinding, 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.IComponent |
addAsset, addBody, addComponent, enterActiveState, finishLoad, getAsset, getAssets, getBeans, getBinding, getBindingNames, getBindings, getComponent, getComponents, getContainer, getExtendedId, getId, getIdPath, getListeners, getMessages, getNamespace, getPage, getProperty, getSpecification, isRendering, renderBody, setBinding, 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 |
ValidField
public ValidField()
getValue
public abstract java.lang.Object getValue()
setValue
public abstract void setValue(java.lang.Object value)
getDisplayName
public abstract java.lang.String getDisplayName()
- Description copied from interface:
IFormComponent
- May be implemented to return a user-presentable, localized name for the component,
which is used in labels or error messages. Most components simply 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 java.lang.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(java.lang.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()