wicket.markup.html.form.TextField
[back to the reference]A Textfield is used to transfer a single line of text. As other form components, textfields update their models as well as they read them it, and you can attach validations (instances of IValidator) to them.
Behind the Scenes
Example HTML
<input type="text" wicket:id="text" />
<input type="text" wicket:id="integer" />
Example Code
// add a simple text field that uses Input's 'text' property. Nothing can go wrong here
form.add(new TextField("text"));
// here we add a text field that uses Input's 'integer' property. Something could go
// wrong here, as the user's (textual) input might be an invalid value for an
// Integer object. If we provide the class constructor argument like we do here, we
// get two things:
// 1. A type validator is added, so that before any actual updating is tried, first the
// user input is checked for validity. When the user input is wrong for an integer,
// the model updating is cancelled, and an error message is displayed to the user
// 2.When updating the model, the given type is explicitly used instead of trying
// to figure out what type should be converted to.
// Note that the default validation message mechanism uses resource bundles for the actual
// message lookup. The message for this component can be found in TextFieldPage.properties
// with key 'form.integer.IConverter'. Read more about how this works in the javadocs
// of AbstractValidator
form.add(new TextField("integer", Integer.class));