apache.
<input>
element. The default is "text", but this can be overridden when using HTML5 types such as "number".Name | Description |
---|---|
parseClient | |
toClient | |
validate |
Once again, we're basing the example on the order payment screen from the Radio examples. This time we're focusing in on the text field used for entering the credit card number, and we're going to validate that number using a regular expression:
<t:label for="cardNumber"/>: <t:textfield t:id="cardNumber" validate="required,regexp" size="20"/>
The validate parameter is used to specify validations for the field. When it is omitted, the @Validate annotation of the property is used (if present). In any case, this references two of the built-in validations: "required" and "regexp".
This example presumes that the Payment page includes a property named "cardNumber".
The "required" validation requires no extra configuration. On the other hand, "regexp" needs to know the regular expression to enforce ... and it should also have a user presentable message.
cardnumber-regexp-message=Credit Card numbers consist of 16 digits cardnumber-regexp=\\d{4}(\\-?\\d{4}){3}
Tapestry uses the page's message catalog as a source of extra validation information. The key is the component id, the name of the validation. The value is given to the validator object ... here it's the regular expression for a credit card number (four sets of four digits, optionally seperated by dashes). The "-message" entry allows the normal error message for the validator to be overridden.
These same approaches apply consistently to all form control element components.
cssClass, decorator, defaultProvider, disabled, environment, fieldValidationSupport, formSupport, javaScriptSupport, label, request, resources, validationTracker
Constructor | Description |
---|---|
TextField() |
Modifier and Type | Method | Description |
---|---|---|
protected void | writeFieldTag(MarkupWriter writer, java.lang.String value) | Invoked from AbstractTextField.begin(MarkupWriter) to write out the element and attributes (typically, <input>). |
getWidth, ignoreBlankInput, isRequired, processSubmission
decorateInsideField, getClientId, getControlName, getLabel, isDisabled, putPropertyNameIntoBeanValidationContext, removePropertyNameFromBeanValidationContext, setDecorator, setFormSupport
public TextField()
protected void writeFieldTag(MarkupWriter writer, java.lang.String value)
AbstractTextField
AbstractTextField.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()
.writeFieldTag
in class AbstractTextField
writer
- markup write to send output tovalue
- the value (either obtained and translated from the value parameter, or obtained from the tracker)