Package com.vaadin.data.validator

Examples of com.vaadin.data.validator.RegexpValidator


import com.vaadin.ui.Form;

public class TestSerialization extends TestCase {

    public void testValidators() throws Exception {
        RegexpValidator validator = new RegexpValidator(".*", "Error");
        validator.validate("aaa");
        RegexpValidator validator2 = serializeAndDeserialize(validator);
        validator2.validate("aaa");
    }
View Full Code Here


            // should fail
        }
    }

    public void testRegexpValidator() {
        field.addValidator(new RegexpValidator("pattern", true,
                "Validation failed"));
        field.setRequired(false);

        // succeeds
        field.setValue("");
View Full Code Here

        form.addField("e", tf);

        // regular expressions

        tf = new TextField("A field, must match the regular expression a.*b.*c");
        tf.addValidator(new RegexpValidator("a.*b.*c",
                "{0} does not match the regular expression"));
        tf.setValue("aagsabeqgc");
        form.addField("f", tf);

        tf = new TextField(
                "A field, must contain the regular expression a.*b.*c");
        tf.addValidator(new RegexpValidator("a.*b.*c", false,
                "{0} does not contain the regular expression"));
        tf.setValue("aagsabeqgc");
        form.addField("g", tf);

        tf = new TextField(
                "A field, must match the regular expression ^a.*b.*c$");
        tf.addValidator(new RegexpValidator("^a.*b.*c$", false,
                "{0} does not match the regular expression with ^ and $"));
        tf.setValue("aagsabeqgc");
        form.addField("h", tf);

        tf = new TextField(
                "A field, must contain the regular expression ^a.*b.*c$");
        tf.addValidator(new RegexpValidator("^a.*b.*c$", false,
                "{0} does not contain the regular expression with ^ and $"));
        tf.setValue("aagsabeqgc");
        form.addField("i", tf);

        // TODO CompositeValidator
View Full Code Here

    public void setInputCaption(String caption) {
      inputField.setCaption(caption);
    }

    public void setInputRegexValidator(String regex, String errorMessage) {
      inputField.addValidator(new RegexpValidator(regex, errorMessage));
    }
View Full Code Here

  protected abstract Layout wrapFields();

  private TextField createTimeField(String timeCaption, String timeErrorMessage) {
    TextField timeField = new TextField(timeCaption);
    timeField.addValidator(new RegexpValidator("(2[0-3]|[0-1]?[0-9])(:[0-5][0-9]){0,2}", timeErrorMessage));
    timeField.setImmediate(true);
    timeField.setWidth(getAdvisedWidth(timeField), Sizeable.UNITS_PIXELS);
    timeField.setNullRepresentation("");
    timeField.addListener(new ValueChangeListener() {
      @Override
View Full Code Here

        AbstractTextField field = iwe.getSecret() != null && iwe.getSecret() ? new PasswordField() : new TextField();
        if (iwe.getMaxLength() != null) {
            field.setMaxLength(iwe.getMaxLength());
        }
        if (hasText(iwe.getRegexp()) && hasText(iwe.getRegexp())) {
            field.addValidator(new RegexpValidator(WidgetDefinitionLoader.replaceXmlEscapeCharacters(iwe.getRegexp()), iwe.getErrorKey() != null ?
                    iwe.getErrorKey() : getMessage("processdata.block.error.regexp").replaceFirst("%s", iwe.getRegexp())));
        }
        if (nvl(iwe.getRequired(), false)) {
            field.setRequired(true);
            if (hasText(iwe.getCaption())) {
View Full Code Here

        field.setImmediate(true);
        field.setSizeFull();
        field.setStyleName("v-colorpicker-preview-textfield");
        field.setData(this);
        field.addValueChangeListener(this);
        field.addValidator(new RegexpValidator("#[0-9a-fA-F]{6}", true, ""));
        addComponent(field);

        setColor(color);
    }
View Full Code Here

TOP

Related Classes of com.vaadin.data.validator.RegexpValidator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.