Class AbstractTextField
java.lang.Object
org.apache.tapestry5.corelib.base.AbstractField
org.apache.tapestry5.corelib.base.AbstractTextField
- All Implemented Interfaces:
ClientElement
,Field
- Direct Known Subclasses:
PasswordField
,TextArea
,TextField
@Events({"toClient","validate","parseClient"})
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
.Name | Type | Flags | Default | Default Prefix |
---|---|---|---|---|
annotationProvider | org. | prop | ||
Provider of annotations used for some defaults. Annotation are usually provided in terms of the value parameter (i.e., from the getter and/or setter bound to the value parameter). | ||||
clientId | String | literal | ||
Used to explicitly set the client-side id of the element for this component. Normally this is not bound (or null) and org.apache.tapestry5.services.javascript.JavaScriptSupport#allocateClientId(org.apache.tapestry5.ComponentResources) is used to generate a unique client-id based on the component's id. In some cases, when creating client-side behaviors, it is useful to explicitly set a unique id for an element using this parameter. Certain values, such as "submit", "method", "reset", etc., will cause client-side conflicts and are not allowed; using such will cause a runtime exception. | ||||
ensureClientIdUnique | boolean | Since 5.4 | prop | |
A rarely used option that indicates that the actual client id should start with the clientId parameter (if non-null) but should still pass that Id through org.apache.tapestry5.services.javascript.JavaScriptSupport#allocateClientId(String) to generate the final id. An example of this are the components used inside a org.apache.tapestry5.corelib.components.BeanEditor which will specify a clientId (based on the property name) but still require that it be unique. Defaults to false. | ||||
nulls | org. | default | nullfieldstrategy | |
Defines how nulls on the server side, or sent from the client side, are treated. The selected strategy may replace the nulls with some other value. The default strategy leaves nulls alone. Another built-in strategy, zero, replaces nulls with the value 0. | ||||
translate | org. | Required, Not Null | translate | |
The object which will perform translation between server-side and client-side representations. If not specified, a value will usually be generated based on the type of the value parameter. | ||||
validate | org. | Not Null | validate | |
The object that will perform input validation (which occurs after translation). The validate binding prefix is generally used to provide this object in a declarative fashion. | ||||
value | Object | Required | prop | |
The value to be read and updated. This is not necessarily a string, a translator may be provided to convert between client side and server side representations. If not bound, a default binding is made to a property of the container matching the component's id. If no such property exists, then you will see a runtime exception due to the unbound value parameter. |
Name | Description |
---|---|
parseClient | |
toClient | |
validate |
-
Field Summary
Fields inherited from class org.apache.tapestry5.corelib.base.AbstractField
cssClass, decorator, defaultProvider, disabled, environment, fieldValidationSupport, formSupport, javaScriptSupport, label, request, resources, validationTracker
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final String
getWidth()
Looks for aWidth
annotation and, if present, returns its value as a string.protected boolean
Should blank input be ignored (after validation)? This will be true forPasswordField
.boolean
Returns false; most components do not support declarative validation.protected void
processSubmission
(String controlName) 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 frombegin(MarkupWriter)
to write out the element and attributes (typically, <input>).Methods inherited from class org.apache.tapestry5.corelib.base.AbstractField
decorateInsideField, getClientId, getControlName, getLabel, isDisabled, putPropertyNameIntoBeanValidationContext, removePropertyNameFromBeanValidationContext, setDecorator, setFormSupport
-
Constructor Details
-
AbstractTextField
public AbstractTextField()
-
-
Method Details
-
writeFieldTag
Invoked frombegin(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 invokeMarkupWriter.element(String, Object[])
, and will be responsible for including anAfterRender
phase method to invokeMarkupWriter.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
Description copied from class:AbstractField
Method implemented by subclasses to actually do the work of processing the submission of the form. The element's controlName property will already have been set. This method is only invoked if the field is notdisabled
.- Specified by:
processSubmission
in classAbstractField
- Parameters:
controlName
- the control name of the rendered element (used to find the correct parameter in the request)
-
ignoreBlankInput
Should blank input be ignored (after validation)? This will be true forPasswordField
.- Returns:
- true if blank input should be ignored, false otherwise
-
isRequired
Description copied from class:AbstractField
Returns false; most components do not support declarative validation.- Specified by:
isRequired
in interfaceField
- Overrides:
isRequired
in classAbstractField
- Returns:
- true if a non-blank value is required for the field
-
getWidth
Looks for aWidth
annotation and, if present, returns its value as a string.- Returns:
- the indicated width, or null if the annotation is not present
-