org.apache.wicket.validation.validator.StringValidator Java Examples

The following examples show how to use org.apache.wicket.validation.validator.StringValidator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UsernameTextField.java    From wicket-spring-boot with Apache License 2.0 5 votes vote down vote up
public UsernameTextField(String id) {
	super(id);
	Injector.get().inject(this);
	add(StringValidator.minimumLength(3));
	setRequired(true);
	add(new UsernameExistsValidator());
}
 
Example #2
Source File: CustomerListPage.java    From wicket-spring-boot with Apache License 2.0 5 votes vote down vote up
public CustomerListPage() {
	FeedbackPanel feedbackPanel = new FeedbackPanel("feedback");
	feedbackPanel.setOutputMarkupId(true);
	add(feedbackPanel);
	
	add(new WebSocketBehavior() {

		@Override
		protected void onPush(WebSocketRequestHandler handler, IWebSocketPushMessage message) {
			if (message instanceof CustomerChangedEvent) {
				CustomerChangedEvent event = (CustomerChangedEvent)message;
				info("changed/created " + event.getCustomer().getFirstname() + " " + event.getCustomer().getLastname());
				handler.add(feedbackPanel);
			}
		}

	});
	
	customerFilterModel = new CompoundPropertyModel<>(new CustomerFilter());
	CustomerDataProvider customerDataProvider = new CustomerDataProvider(customerFilterModel);
	
	queue(new BookmarkablePageLink<Customer>("create", CustomerCreatePage.class));
	
	queue(new ValidationForm<>("form", customerFilterModel));
	queue(new LabeledFormBorder<>(getString("id"), new TextField<>("id")));
	queue(new LabeledFormBorder<>(getString("username"), new UsernameSearchTextField("usernameLike")));
	queue(new LabeledFormBorder<>(getString("firstname"), new TextField<String>("firstnameLike").add(StringValidator.minimumLength(3))));
	queue(new LabeledFormBorder<>(getString("lastname"), new TextField<String>("lastnameLike").add(StringValidator.minimumLength(3))));
	queue(new LabeledFormBorder<>(getString("active"), new CheckBox("active")));
	queue(cancelButton());
	
	customerDataTable(customerDataProvider);

}
 
Example #3
Source File: AjaxTextFieldITCase.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Test
public void nullIsNotValidated() {
    TestPage<String, AjaxTextFieldPanel> testPage =
            new TestPage.Builder<String, AjaxTextFieldPanel>().build(
                    new AjaxTextFieldPanel(TestPage.FIELD, TestPage.FIELD, TEXT_MODEL));
    testPage.getFieldPanel().getField().setRequired(false);
    testPage.getFieldPanel().getField().add(StringValidator.minimumLength(2));
    TESTER.startPage(testPage);
    FormTester formTester = TESTER.newFormTester(testPage.getForm().getId());
    formTester.setValue("field:textField", "");
    formTester.submit();
    assertNull(testPage.getFieldPanel().getDefaultModelObject());
    assertTrue(testPage.getFieldPanel().getField().isValid());
}
 
Example #4
Source File: PFAutoCompleteMaxLengthTextField.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
private void init(final Integer maxLength)
{
  if (maxLength != null) {
    add(StringValidator.maximumLength(maxLength));
    //add(AttributeModifier.replace("maxlength", String.valueOf(maxLength))); // Done by StringValidator
  }
}
 
Example #5
Source File: AjaxMaxLengthEditableLabel.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
private void init(final String id, final Integer maxLength)
{
  if (maxLength != null) {
    add(StringValidator.maximumLength(maxLength));
    // add(AttributeModifier.replace("maxlength", String.valueOf(maxLength))); // Done by StringValidator
  }
}
 
Example #6
Source File: MaxLengthTextArea.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
private void init(final String id, final Integer maxLength)
{
  if (maxLength != null) {
    add(StringValidator.maximumLength(maxLength));
    // add(AttributeModifier.replace("maxlength", String.valueOf(maxLength))); // Not supported by html textarea!
    this.maxLength = maxLength;
  }
}
 
Example #7
Source File: MaxLengthTextField.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
private void init(final String id, final Integer maxLength)
{
  if (maxLength != null) {
    add(StringValidator.maximumLength(maxLength));
    // add(AttributeModifier.replace("maxlength", String.valueOf(maxLength))); // Field maxlength is produced by StringValidator.
  }
}
 
Example #8
Source File: ContactPage.java    From yes-cart with Apache License 2.0 4 votes vote down vote up
/**
 * Construct form.
 *
 * @param id             form id.
 */
public ContactForm(final String id, final IValidator<String> emailValidator) {

    super(id);

    setModel(new CompoundPropertyModel<>(ContactForm.this));


    add(
            new TextField<String>("email")
                    .setRequired(true)
                    .add(emailValidator)
    );

    add(
            new TextField<String>("name")
                    .setRequired(true)
    );

    add(
            new TextField<String>("subject")
                    .setRequired(true)
    );

    add(
            new TextField<String>("phone")
                    .setRequired(true)
                    .add(StringValidator.lengthBetween(4, 13))
    );

    add(
            new TextArea<String>("message")
                    .setRequired(true)
    );


    add(
            new Button("sendBtn") {


                @Override
                public void onSubmit() {

                    final Map<String, Object> data = new HashMap<>();
                    data.put("name", getName());
                    data.put("phone", getPhone());
                    data.put("email", getEmail());
                    data.put("subject", getSubject());
                    data.put("body", getMessage());

                    getCustomerServiceFacade().registerEmailRequest(
                            getCurrentShop(), email, data);

                    info(
                            getLocalizer().getString("emailSend", this)
                    );

                    setEmail(null);
                    setPhone(null);
                    setName(null);
                    setSubject(null);
                    setMessage(null);

                }
            }
    );

}
 
Example #9
Source File: UsernameSearchTextField.java    From wicket-spring-boot with Apache License 2.0 4 votes vote down vote up
private void initComponent() {
	add(StringValidator.minimumLength(MINIMUM_INPUT_LENGTH));
}