Search in sources :

Example 1 with StringValidator

use of org.apache.wicket.validation.validator.StringValidator in project wicket by apache.

the class FormPage method addFormComponents.

private void addFormComponents(final Form<Bean> form) {
    FormComponent<String> fc = new RequiredTextField<>("name");
    fc.add(new StringValidator(4, null));
    fc.setLabel(new ResourceModel("label.name"));
    // add AjaxPreventSubmitBehavior to the text field if it mustn't submit
    // the form when ENTER is pressed
    // fc.add(new AjaxPreventSubmitBehavior());
    form.add(fc);
    form.add(new SimpleFormComponentLabel("name-label", fc));
    fc = new RequiredTextField<>("email");
    fc.add(EmailAddressValidator.getInstance());
    fc.setLabel(new ResourceModel("label.email"));
    form.add(fc);
    form.add(new SimpleFormComponentLabel("email-label", fc));
}
Also used : StringValidator(org.apache.wicket.validation.validator.StringValidator) ResourceModel(org.apache.wicket.model.ResourceModel) RequiredTextField(org.apache.wicket.markup.html.form.RequiredTextField) SimpleFormComponentLabel(org.apache.wicket.markup.html.form.SimpleFormComponentLabel)

Aggregations

RequiredTextField (org.apache.wicket.markup.html.form.RequiredTextField)1 SimpleFormComponentLabel (org.apache.wicket.markup.html.form.SimpleFormComponentLabel)1 ResourceModel (org.apache.wicket.model.ResourceModel)1 StringValidator (org.apache.wicket.validation.validator.StringValidator)1