Example usage for org.apache.wicket.validation.validator PatternValidator PatternValidator

List of usage examples for org.apache.wicket.validation.validator PatternValidator PatternValidator

Introduction

In this page you can find the example usage for org.apache.wicket.validation.validator PatternValidator PatternValidator.

Prototype

public PatternValidator(final MetaPattern pattern) 

Source Link

Document

Constructor that accepts a MetaPattern argument.

Usage

From source file:au.org.theark.core.web.component.customfield.form.DetailForm.java

License:Open Source License

protected void attachValidators() {
    fieldNameTxtFld.setRequired(true).setLabel((new StringResourceModel("customField.name.required", this,
            new Model<String>("Custom Field Name"))));
    // Enforce particular characters for fieldName
    fieldNameTxtFld.add(new PatternValidator("[a-zA-Z0-9_-]+"));
    //Ark-1591 error fixing .
    fieldNameTxtFld/*from w  ww.j  av a2 s.co m*/
            .add(StringValidator.maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_NAME_MAX_LENGTH_50));
    fieldDescriptionTxtAreaFld.add(StringValidator
            .maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_DESCRIPTIVE_MAX_LENGTH_255));

    fieldTypeDdc.setRequired(true).setLabel(
            (new StringResourceModel("customField.fieldType.required", this, new Model<String>("Field Type"))));
    fieldLabelTxtAreaFld.add(StringValidator
            .maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_DESCRIPTIVE_MAX_LENGTH_255));
    fieldUnitTypeTxtFld
            .add(StringValidator.maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_NAME_MAX_LENGTH_50));
    //defaultValueTextArea.add(StringValidator.maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_DESCRIPTIVE_MAX_LENGTH_255));
    // TODO: Add correct validator, possibly custom with better validation message
    fieldEncodedValuesTxtFld.add(new PatternValidator(au.org.theark.core.Constants.ENCODED_VALUES_PATTERN))
            .setLabel(new StringResourceModel("customField.encodedValues.validation", this,
                    new Model<String>("Encoded Value definition")));

    customFieldTypeDdc.setRequired(true)
            .setLabel((new StringResourceModel("customField.customtfieldType.required", this,
                    new Model<String>("Custom Field Type"))));
}

From source file:au.org.theark.core.web.component.customfieldcategory.form.DetailForm.java

License:Open Source License

protected void attachValidators() {
    categoryNameTxtFld.setRequired(true);
    categoryNameTxtFld.add(new PatternValidator("[a-zA-Z0-9_-]+"));
    categoryNameTxtFld//w  w w.j  a va2  s.  c  o  m
            .add(StringValidator.maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_NAME_MAX_LENGTH_50));

    categoryDescriptionTxtAreaFld.add(StringValidator
            .maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_DESCRIPTIVE_MAX_LENGTH_255));
    customFieldTypeDdc.setRequired(true);
    categoryOrderNoTxtFld.setRequired(true);
    categoryOrderNoTxtFld.add(new RangeValidator<Long>(
            new Long(au.org.theark.core.Constants.GENERAL_FIELD_WHOLE_NUMBER_MIN_QUANTITY_1),
            new Long(au.org.theark.core.Constants.GENERAL_FIELD_WHOLE_NUMBER_MAX_QUANTITY_100)));

}

From source file:au.org.theark.core.web.component.customfieldcategory.form.SearchForm.java

License:Open Source License

private void addValidators() {
    categoryNameTxtFld.add(new PatternValidator("[a-zA-Z0-9_-]+"));
    categoryDescriptionTxtAreaFld.add(new PatternValidator("[a-zA-Z0-9_-]+"));
}

From source file:au.org.theark.phenotypic.web.component.phenodatacategory.form.DetailForm.java

License:Open Source License

protected void attachValidators() {
    categoryNameTxtFld.setRequired(true);
    categoryNameTxtFld.add(new PatternValidator("[a-zA-Z0-9_-]+"));
    categoryNameTxtFld/*from  w w  w  .  j av  a2  s  . c  o m*/
            .add(StringValidator.maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_NAME_MAX_LENGTH_50));
    categoryDescriptionTxtAreaFld.add(StringValidator
            .maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_DESCRIPTIVE_MAX_LENGTH_255));
}

From source file:au.org.theark.phenotypic.web.component.phenodatadictionary.form.DetailForm.java

License:Open Source License

protected void attachValidators() {
    fieldNameTxtFld.setRequired(true).setLabel((new StringResourceModel("phenoDataSetField.name.required", this,
            new Model<String>("Custom Field Name"))));
    // Enforce particular characters for fieldName
    fieldNameTxtFld.add(new PatternValidator("[a-zA-Z0-9_-]+"));
    fieldNameTxtFld//  w ww.j ava 2  s .co m
            .add(StringValidator.maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_NAME_MAX_LENGTH_50));
    fieldDescriptionTxtAreaFld.add(StringValidator
            .maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_DESCRIPTIVE_MAX_LENGTH_255));
    fieldTypeDdc.setRequired(true).setLabel((new StringResourceModel("phenoDataSetField.fieldType.required",
            this, new Model<String>("Custom Field Type"))));
    fieldLabelTxtAreaFld.add(StringValidator.maximumLength(255));
    fieldUnitTypeTxtFld
            .add(StringValidator.maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_NAME_MAX_LENGTH_50));
    //defaultValueTextArea.add(StringValidator.maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_DESCRIPTIVE_MAX_LENGTH_255));
    // TODO: Add correct validator, possibly phenoDataSet with better validation message
    fieldEncodedValuesTxtFld.add(new PatternValidator(au.org.theark.core.Constants.ENCODED_VALUES_PATTERN))
            .setLabel(new StringResourceModel("phenoDataSetField.encodedValues.validation", this,
                    new Model<String>("Encoded Value definition")));

}

From source file:au.org.theark.study.web.component.manageuser.form.DetailForm.java

License:Open Source License

@Override
protected void attachValidators() {
    lastNameTxtField.add(StringValidator.lengthBetween(1, 50))
            .setLabel(new StringResourceModel("lastName", this, null));
    lastNameTxtField.setRequired(true);// w  ww . ja v a2  s  .  co m

    userNameTxtField.add(StringValidator.lengthBetween(1, 50))
            .setLabel(new StringResourceModel("userName", this, null));
    userNameTxtField.add(EmailAddressValidator.getInstance())
            .setLabel(new StringResourceModel("userName.incorrectPattern", this, null));
    userNameTxtField.setRequired(true).setLabel(new StringResourceModel("userName", this, null));

    firstNameTxtField.setRequired(true).setLabel(new StringResourceModel("firstName", this, null));
    firstNameTxtField.add(StringValidator.lengthBetween(1, 50))
            .setLabel(new StringResourceModel("firstName", this, null));

    emailTxtField.add(StringValidator.lengthBetween(1, 50))
            .setLabel(new StringResourceModel("email", this, null));
    emailTxtField.add(EmailAddressValidator.getInstance())
            .setLabel(new StringResourceModel("email.incorrectpattern", this, null));
    emailTxtField.setRequired(true).setLabel(new StringResourceModel("email", this, null));

    userPasswordField.setRequired(isNew());
    confirmPasswordField.setRequired(isNew());

    // Set the confirm password with a password pattern
    userPasswordField.setLabel(Model.of("Password"));
    userPasswordField.add(new PatternValidator(Constants.PASSWORD_PATTERN));
    confirmPasswordField.setLabel(Model.of("Confirm Password"));
}

From source file:au.org.theark.study.web.component.mydetails.form.MyDetailsForm.java

License:Open Source License

private void attachValidators() {
    userNameTxtField.add(EmailAddressValidator.getInstance())
            .setLabel(new StringResourceModel("userName.incorrect.format", this, null));
    userNameTxtField.setRequired(true).setLabel(new StringResourceModel("userName", this, null));
    userNameTxtField.add(StringValidator.lengthBetween(3, 50))
            .setLabel(new StringResourceModel("userName", this, null));

    firstNameTxtField.setRequired(true).setLabel(new StringResourceModel("firstName", this, null));
    firstNameTxtField.add(StringValidator.lengthBetween(3, 50))
            .setLabel(new StringResourceModel("firstName", this, null));

    emailTxtField.add(EmailAddressValidator.getInstance())
            .setLabel(new StringResourceModel("email.incorrect.format", this, null));
    emailTxtField.setRequired(true).setLabel(new StringResourceModel("email", this, null));

    lastNameTxtField.add(StringValidator.lengthBetween(3, 50))
            .setLabel(new StringResourceModel("lastNameLength", this, null));
    lastNameTxtField.setRequired(true).setLabel(new StringResourceModel("lastName", this, null));

    userPasswordField.setRequired(false);
    confirmPasswordField.setRequired(false);

    userPasswordField.setLabel(Model.of("Password"));
    userPasswordField.add(new PatternValidator(Constants.PASSWORD_PATTERN));
    confirmPasswordField.setLabel(Model.of("Confirm Password"));
}

From source file:by.grodno.ss.rentacar.webapp.page.admin.panel.UserEditPanel.java

@Override
public void onInitialize() {
    super.onInitialize();
    UserEditPanel.this.setOutputMarkupId(true);

    Form<UserProfile> form = new Form<UserProfile>("form", new CompoundPropertyModel<UserProfile>(userProfile));

    TextField<String> created = new TextField<String>("created");
    created.setEnabled(false);//  w  ww.  jav a2  s.  c  o m
    form.add(created);

    TextField<String> email = new TextField<String>("email", new PropertyModel<>(userCredentials, "email"));
    email.setRequired(true);
    email.add(StringValidator.maximumLength(100));
    email.add(StringValidator.minimumLength(3));
    email.add(EmailAddressValidator.getInstance());
    form.add(email);

    DropDownChoice<UserRole> roleDropDown = new DropDownChoice<>("role",
            new PropertyModel<>(userCredentials, "role"), Arrays.asList(UserRole.values()),
            UserRoleChoiceRenderer.INSTANCE);
    roleDropDown.setRequired(true);
    form.add(roleDropDown);

    TextField<String> firstName = new TextField<String>("firstName");
    firstName.setRequired(true);
    firstName.add(StringValidator.maximumLength(100));
    firstName.add(StringValidator.minimumLength(2));
    firstName.add(new PatternValidator("[A-Za-z]+"));
    form.add(firstName);

    TextField<String> lastName = new TextField<String>("lastName");
    lastName.setRequired(true);
    lastName.add(StringValidator.maximumLength(100));
    lastName.add(StringValidator.minimumLength(2));
    lastName.add(new PatternValidator("[A-Za-z]+"));
    form.add(lastName);

    TextField<String> phone = new TextField<String>("phoneNumber");
    phone.setRequired(true);
    phone.add(StringValidator.maximumLength(100));
    phone.add(StringValidator.minimumLength(2));
    phone.add(new PatternValidator("[0-9+()-]+"));
    form.add(phone);

    TextField<String> licNumber = new TextField<String>("licenseNumber");
    licNumber.add(StringValidator.maximumLength(100));
    licNumber.add(StringValidator.minimumLength(2));
    licNumber.add(new PatternValidator("[A-Za-z0-9]+"));
    form.add(licNumber);

    DateTextFieldConfig config = new DateTextFieldConfig();
    config.withLanguage(AuthorizedSession.get().getLocale().getLanguage());
    config.withFormat("dd.MM.yyyy");
    DateTextField dateBirth = new DateTextField("birthDay", config);
    form.add(dateBirth);

    TextField<String> address = new TextField<String>("address");
    address.add(StringValidator.maximumLength(100));
    address.add(StringValidator.minimumLength(2));
    address.add(new PatternValidator("[A-Za-z0-9 /-]+"));
    form.add(address);

    TextField<String> city = new TextField<String>("city");
    city.add(StringValidator.maximumLength(100));
    city.add(StringValidator.minimumLength(2));
    city.add(new PatternValidator("[A-Za-z0-9]+"));
    form.add(city);

    TextField<String> region = new TextField<String>("region");
    region.add(StringValidator.maximumLength(100));
    region.add(StringValidator.minimumLength(2));
    region.add(new PatternValidator("[A-Za-z0-9]+"));
    form.add(region);

    TextField<String> zip = new TextField<String>("zipCode");
    zip.add(StringValidator.maximumLength(20));
    zip.add(StringValidator.minimumLength(2));
    zip.add(new PatternValidator("[0-9]+"));
    form.add(zip);

    WebMarkupContainer passTable = new WebMarkupContainer("pass-table");
    passTable.setOutputMarkupId(true);

    WebMarkupContainer trPass = new WebMarkupContainer("pass");
    WebMarkupContainer trCpass = new WebMarkupContainer("cpass");
    if (userProfile.getId() == null) {
        trPass.setVisible(true);
        trCpass.setVisible(true);
    } else {
        trPass.setVisible(false);
        trCpass.setVisible(false);
    }
    trPass.setOutputMarkupId(true);
    trCpass.setOutputMarkupId(true);

    PasswordTextField password = new PasswordTextField("password",
            new PropertyModel<>(userCredentials, "password"));
    trPass.add(password);
    PasswordTextField cpassword = new PasswordTextField("cpassword", Model.of(""));
    trCpass.add(cpassword);

    passTable.add(trPass);
    passTable.add(trCpass);
    form.add(passTable);
    form.add(new EqualPasswordInputValidator(password, cpassword));

    AjaxLink<Void> changePass = new AjaxLink<Void>("change-password") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (!trPass.isVisible()) {
                trPass.setVisible(true);
                trCpass.setVisible(true);
                passTable.add(trPass);
                passTable.add(trCpass);
            } else {
                trPass.setVisible(false);
                trCpass.setVisible(false);
            }
            if (target != null) {
                target.add(passTable);
            }
        }
    };
    if (userProfile.getId() == null) {
        changePass.setVisible(false);
    }
    form.add(changePass);

    form.add(new SubmitLink("save") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onSubmit() {
            if (userProfile.getId() == null) {
                userService.register(userProfile, userCredentials);
            } else {
                userService.update(userProfile);
                userService.update(userCredentials);
            }
            info("User was saved");
        }
    });

    boolean a = (AuthorizedSession.get().isSignedIn()
            && AuthorizedSession.get().getLoggedUser().getRole().equals(UserRole.ADMIN));
    form.setEnabled(a);
    add(form);

    add(new AjaxLink<Void>("back") {
        private static final long serialVersionUID = 1L;

        public void onClick(AjaxRequestTarget target) {
            Component newPanel = new UserListPanel(UserEditPanel.this.getId(), filter);
            UserEditPanel.this.replaceWith(newPanel);
            if (target != null) {
                target.add(newPanel);
            }
        }
    });
}

From source file:by.grodno.ss.rentacar.webapp.page.MyBooking.ProfileEditPanel.java

@Override
public void onInitialize() {
    super.onInitialize();
    final NotificationPanel feedback = new NotificationPanel("feedbackpanel");
    add(feedback);/*from  ww  w .ja va2s.c  o m*/

    Form<UserProfile> form = new Form<UserProfile>("form", new CompoundPropertyModel<UserProfile>(userProfile));

    TextField<String> firstName = new TextField<String>("firstName");
    firstName.setRequired(true);
    firstName.add(StringValidator.maximumLength(100));
    firstName.add(StringValidator.minimumLength(2));
    firstName.add(new PatternValidator("[A-Za-z]+"));
    form.add(firstName);

    TextField<String> lastName = new TextField<String>("lastName");
    lastName.setRequired(true);
    lastName.add(StringValidator.maximumLength(100));
    lastName.add(StringValidator.minimumLength(2));
    lastName.add(new PatternValidator("[A-Za-z]+"));
    form.add(lastName);

    TextField<String> phone = new TextField<String>("phoneNumber");
    phone.setRequired(true);
    phone.add(StringValidator.maximumLength(100));
    phone.add(StringValidator.minimumLength(2));
    phone.add(new PatternValidator("[0-9+()-]+"));
    form.add(phone);

    TextField<String> licNumber = new TextField<String>("licenseNumber");
    licNumber.add(StringValidator.maximumLength(100));
    licNumber.add(StringValidator.minimumLength(2));
    licNumber.add(new PatternValidator("[A-Za-z0-9]+"));
    form.add(licNumber);

    DateTextFieldConfig config = new DateTextFieldConfig();
    config.withLanguage(AuthorizedSession.get().getLocale().getLanguage());
    config.withFormat("dd.MM.yyyy");
    DateTextField dateBirth = new DateTextField("birthDay", config);
    form.add(dateBirth);

    TextField<String> address = new TextField<String>("address");
    address.add(StringValidator.maximumLength(100));
    address.add(StringValidator.minimumLength(2));
    address.add(new PatternValidator("[A-Za-z0-9 /-]+"));
    form.add(address);

    TextField<String> city = new TextField<String>("city");
    city.add(StringValidator.maximumLength(100));
    city.add(StringValidator.minimumLength(2));
    city.add(new PatternValidator("[A-Za-z0-9]+"));
    form.add(city);

    TextField<String> region = new TextField<String>("region");
    region.add(StringValidator.maximumLength(100));
    region.add(StringValidator.minimumLength(2));
    region.add(new PatternValidator("[A-Za-z0-9]+"));
    form.add(region);

    TextField<String> zip = new TextField<String>("zipCode");
    zip.add(StringValidator.maximumLength(20));
    zip.add(StringValidator.minimumLength(2));
    zip.add(new PatternValidator("[0-9]+"));
    form.add(zip);

    Label email = new Label("email", new PropertyModel<>(userCredentials, "email"));
    form.add(email);

    WebMarkupContainer passTable = new WebMarkupContainer("pass-table");
    passTable.setOutputMarkupId(true);

    WebMarkupContainer trPass = new WebMarkupContainer("pass");
    WebMarkupContainer trCpass = new WebMarkupContainer("cpass");
    if (userProfile.getId() == null) {
        trPass.setVisible(true);
        trCpass.setVisible(true);
    } else {
        trPass.setVisible(false);
        trCpass.setVisible(false);
    }
    trPass.setOutputMarkupId(true);
    trCpass.setOutputMarkupId(true);

    PasswordTextField password = new PasswordTextField("password",
            new PropertyModel<>(userCredentials, "password"));
    trPass.add(password);
    PasswordTextField cpassword = new PasswordTextField("cpassword", Model.of(""));
    trCpass.add(cpassword);

    passTable.add(trPass);
    passTable.add(trCpass);
    form.add(passTable);
    form.add(new EqualPasswordInputValidator(password, cpassword));

    AjaxLink<Void> changePass = new AjaxLink<Void>("change-password") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (!trPass.isVisible()) {
                trPass.setVisible(true);
                trCpass.setVisible(true);
                passTable.add(trPass);
                passTable.add(trCpass);
            } else {
                trPass.setVisible(false);
                trCpass.setVisible(false);
            }
            if (target != null) {
                target.add(passTable);
            }
        }
    };
    if (userProfile.getId() == null) {
        changePass.setVisible(false);
    }
    form.add(changePass);

    form.add(new SubmitLink("save") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onSubmit() {
            if (userProfile.getId() == null) {
                error("saving error");
            } else {
                userService.update(userProfile);
                userService.update(userCredentials);
            }
            info("User was saved");
        }
    });
    add(form);

    add(new Link<Void>("back") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            setResponsePage(new MyBookingPage());
        }
    });
}

From source file:by.grodno.ss.rentacar.webapp.page.order.CheckoutPage.java

@Override
protected void onInitialize() {
    super.onInitialize();
    final NotificationPanel feedback = new NotificationPanel("feedbackpanel");

    SimpleDateFormat dt = new SimpleDateFormat("dd.MM.yyy HH:mm");
    add(new Label("duration",
            bookingService.convertDurationToString(filter.getDateFrom(), filter.getDateTo())));
    add(new Label("dateFrom", dt.format(filter.getDateFrom())));
    add(new Label("locationFrom", filter.getLocationFrom().getName()));
    add(new Label("dateTo", dt.format(filter.getDateTo())));
    add(new Label("locationTo", filter.getLocationTo().getName()));
    add(new Link<Void>("link-change") {
        private static final long serialVersionUID = 1L;

        @Override/*from  w w  w  .  j ava 2 s .c om*/
        public void onClick() {
            setResponsePage(new ReservationPage(filter));
        }
    });
    add(new Link<Void>("link-change-car") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            setResponsePage(new ChooseCarPage(filter));
        }
    });
    addImage(car);
    add(new Label("name", car.getName()));
    add(new Label("type", car.getType().getName()));
    add(new Label("pass", car.getType().getNumPassengers()));
    add(new Label("bags", car.getType().getNumBags()));
    add(new Label("doors", car.getType().getNumDoors()));
    add(new Label("trans", car.getType().getTransmissionType()));

    add(new Label("rental-duration",
            bookingService.convertDurationToString(filter.getDateFrom(), filter.getDateTo())));
    BigDecimal pricePerHour = car.getType().getPricePerHour();
    totalPrice = bookingService.getTotalPrice(filter.getDateFrom(), filter.getDateTo(), pricePerHour);
    BigDecimal pricePerDay = bookingService.getPricePerDay(pricePerHour);
    int percent = settingService.get().getDepositPayment();
    BigDecimal requiredDeposit = bookingService.getRequiredDeposit(totalPrice, percent);
    add(new Label("pricePerHour", pricePerHour.toString()));
    add(new Label("total", totalPrice.toString()));
    add(new Label("pricePerDay", pricePerDay.toString()));
    add(new Label("requiredDeposit", requiredDeposit.toString()));
    add(new Label("total1", totalPrice.toString()));
    add(new Label("percent", percent));
    add(getPriceIcon("iconPrice1"));
    add(getPriceIcon("iconPrice2"));
    add(getPriceIcon("iconPrice3"));
    add(getPriceIcon("iconPrice4"));
    add(getPriceIcon("iconPrice5"));

    // -----checkout form------------
    Form<UserProfile> form = new Form<UserProfile>("form-checkout",
            new CompoundPropertyModel<UserProfile>(userProfile));
    // form.add(new FeedbackPanel("feedbackpanel"));

    TextField<String> firstName = new TextField<String>("firstName",
            new PropertyModel<>(userProfile, "firstName"));
    firstName.setRequired(true);
    firstName.add(StringValidator.maximumLength(100));
    firstName.add(StringValidator.minimumLength(2));
    firstName.add(new PatternValidator("[A-Za-z]+"));
    form.add(firstName);

    TextField<String> lastName = new TextField<String>("lastName",
            new PropertyModel<>(userProfile, "lastName"));
    lastName.setRequired(true);
    lastName.add(StringValidator.maximumLength(100));
    lastName.add(StringValidator.minimumLength(2));
    firstName.add(new PatternValidator("[A-Za-z]+"));
    form.add(lastName);

    TextField<String> phone = new TextField<String>("phone", new PropertyModel<>(userProfile, "phoneNumber"));
    phone.setRequired(true);
    phone.add(StringValidator.maximumLength(100));
    phone.add(StringValidator.minimumLength(2));
    phone.add(new PatternValidator("[0-9+()-]+"));
    form.add(phone);

    DateTextFieldConfig config = new DateTextFieldConfig();
    config.withLanguage(AuthorizedSession.get().getLocale().getLanguage());
    config.withFormat("dd.MM.yyyy");
    DateTextField dateBirth = new DateTextField("date-birth", new PropertyModel<>(userProfile, "birthDay"),
            config);
    form.add(dateBirth);

    TextField<String> licNumber = new TextField<String>("lic-number",
            new PropertyModel<>(userProfile, "licenseNumber"));
    licNumber.add(StringValidator.maximumLength(100));
    licNumber.add(StringValidator.minimumLength(2));
    licNumber.add(new PatternValidator("[A-Za-z0-9]+"));
    form.add(licNumber);

    TextField<String> note = new TextField<String>("note", new PropertyModel<>(booking, "note"));
    note.add(StringValidator.maximumLength(500));
    form.add(note);

    TextField<String> address = new TextField<String>("address", new PropertyModel<>(userProfile, "address"));
    address.add(StringValidator.maximumLength(100));
    address.add(StringValidator.minimumLength(2));
    address.add(new PatternValidator("[A-Za-z0-9 /-]+"));
    form.add(address);

    TextField<String> city = new TextField<String>("city", new PropertyModel<>(userProfile, "city"));
    city.add(StringValidator.maximumLength(100));
    city.add(StringValidator.minimumLength(2));
    city.add(new PatternValidator("[A-Za-z0-9]+"));
    form.add(city);

    TextField<String> region = new TextField<String>("region", new PropertyModel<>(userProfile, "region"));
    region.add(StringValidator.maximumLength(100));
    region.add(StringValidator.minimumLength(2));
    region.add(new PatternValidator("[A-Za-z0-9]+"));
    form.add(region);

    TextField<String> zip = new TextField<String>("zip-code", new PropertyModel<>(userProfile, "zipCode"));
    zip.add(StringValidator.maximumLength(20));
    zip.add(StringValidator.minimumLength(2));
    zip.add(new PatternValidator("[0-9]+"));
    form.add(zip);

    BootstrapCheckBoxPicker chk0 = new BootstrapCheckBoxPicker("check-confirm", Model.of(Boolean.FALSE));
    form.add(chk0);

    form.add(new SubmitLink("button-confirm") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onSubmit() {
            if (chk0.getModelObject().equals(false)) {
                info("You must to agree rental terms");
            } else {
                if (userProfile.getId() == null) {
                    userCredential.setEmail("unregistered user");
                    userCredential.setPassword("pswd");
                    userCredential.setRole(UserRole.UNREGISTERED);
                    userService.register(userProfile, userCredential);
                } else {
                    userService.update(userProfile);
                }
                booking.setSumm(totalPrice);
                booking.setClient(userProfile);
                booking.setOrderStatus(OrderStatus.pending);
                bookingService.saveOrUpdate(booking);
                setResponsePage(new ConfirmPage());
            }
        }
    });

    form.add(feedback);
    add(form);

}