org.apache.tapestry.corelib.base
Class AbstractTextField
java.lang.Object
org.apache.tapestry.corelib.base.AbstractField
org.apache.tapestry.corelib.base.AbstractTextField
- All Implemented Interfaces:
- ClientElement, Field
- Direct Known Subclasses:
- PasswordField, TextArea, TextField
public abstract class AbstractTextField
- extends AbstractField
Abstract class for a variety of components that render some variation of a text field. Most of the hooks for user
input validation are in this class.
In particular, all subclasses support the "toclient" and "parseclient" events. These two events allow the normal
Translator (specified by the translate parameter, but often automatically derived by Tapestry) to be
augmented.
If the component container (i.e., the page) provides an event handler method for the "toclient" event, and that
handler returns a non-null string, that will be the string value sent to the client. The context passed to the event
handler method is t he current value of the value parameter.
Likewise, on a form submit, the "parseclient" event handler method will be passed the string provided by the client,
and may provide a non-null value as the parsed value. Returning null allows the normal translator to operate. The
event handler may also throw ValidationException.
|
Method Summary |
protected String |
getWidth()
Looks for a Width annotation and, if present, returns its value as a
string. |
boolean |
isRequired()
Returns false; most components do not support declarative validation. |
protected void |
processSubmission(String elementName)
Method implemented by subclasses to actually do the work of processing the submission of the form. |
protected abstract void |
writeFieldTag(MarkupWriter writer,
String value)
Invoked from begin(MarkupWriter) to write out the element and attributes (typically, <input>). |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AbstractTextField
public AbstractTextField()
writeFieldTag
protected abstract void writeFieldTag(MarkupWriter writer,
String value)
- Invoked from
begin(MarkupWriter) to write out the element and attributes (typically, <input>). The
controlName and clientId
properties will already have been set or updated.
Generally, the subclass will invoke MarkupWriter.element(String, Object[]), and will be responsible for
including an AfterRender phase method to invoke MarkupWriter.end().
- Parameters:
writer - markup write to send output tovalue - the value (either obtained and translated from the value parameter, or obtained from the tracker)
processSubmission
protected final void processSubmission(String elementName)
- Description copied from class:
AbstractField
- Method implemented by subclasses to actually do the work of processing the submission of the form. The element's
elementName property will already have been set. This method is only invoked if the field is not
disabled.
- Specified by:
processSubmission in class AbstractField
- Parameters:
elementName - the name of the element (used to find the correct parameter in the request)
isRequired
public boolean isRequired()
- Description copied from class:
AbstractField
- Returns false; most components do not support declarative validation.
- Specified by:
isRequired in interface Field- Overrides:
isRequired in class AbstractField
- Returns:
- true if a non-blank value is required for the field
getWidth
protected final String getWidth()
- Looks for a
Width annotation and, if present, returns its value as a
string.
- Returns:
- the indicated width, or null if the annotation is not present
Copyright © 2006-2008 Apache Software Foundation. All Rights Reserved.