Package com.vaadin.data.validator

Examples of com.vaadin.data.validator.DoubleValidator


        tf.setValue("-321");
        form.addField("c", tf);

        tf = new TextField(
                "A field, must contain a floating point number or be empty");
        tf.addValidator(new DoubleValidator("Invalid double {0}"));
        tf.setValue("-123.45e6");
        form.addField("d", tf);

        tf = new TextField(
                "A field, must contain an e-mail address or be empty");
        tf.addValidator(new EmailValidator("Invalid e-mail address {0}"));
        tf.setValue("a.b@example.com");
        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
        tf = new TextField(
                "A field, must be a floating point number with 4-5 chars");
        CompositeValidator cv = new CompositeValidator(CombinationMode.AND,
                "The field must contain a floating point number with 4-5 characters");
        cv.addValidator(new StringLengthValidator(
                "String length of '{0}' should be 4-5 characters", 4, 5, false));
        cv.addValidator(new DoubleValidator(
                "{0} must be a floating point number"));
        tf.addValidator(cv);
        tf.setValue("12.34");
        form.addField("j", tf);

        tf = new TextField(
                "A field, must be a floating point number or 4-5 chars");
        cv = new CompositeValidator(CombinationMode.OR,
                "The field must contain a floating point  or with 4-5 characters");
        cv.addValidator(new StringLengthValidator(
                "String length of '{0}' should be 4-5 characters", 4, 5, false));
        cv.addValidator(new DoubleValidator(
                "{0} must be a floating point number"));
        tf.addValidator(cv);
        tf.setValue("12.34g");
        form.addField("jb", tf);

View Full Code Here


        addComponent(tf);

        tf = createIntegerTextField();
        tf.setCaption("Enter a double");
        tf.setPropertyDataSource(new ObjectProperty<Double>(2.1));
        tf.addValidator(new DoubleValidator("Must be a Double"));
        addComponent(tf);
    }
View Full Code Here

    dateField.setResolution(DateField.RESOLUTION_MONTH);
    form.addField("month", dateField);
    final TextField textField = new TextField("Wartość");
    textField.setRequired(true);
    textField.setValue("100.99");
    textField.addValidator(new DoubleValidator("Tylko wartości liczbowe"));
    form.addField("value", textField);
    window.addComponent(form);
    Button button = new Button("Zapisz", form, "commit");
    button.setIcon(new ThemeResource("../runo/icons/16/ok.png"));
    button.addListener(new ClickListener() {
View Full Code Here

                if (valueType != null) {
                    if ("int".equalsIgnoreCase(valueType)) {
                        textField.addValidator(new IntegerValidator(source.getMessage("validate.integer")));
                    }
                    else if ("dbl".equalsIgnoreCase(valueType)) {
                        textField.addValidator(new DoubleValidator(source.getMessage("validate.double")));
                    }
                }
                textField.setWidth("100%");
                field = textField;
            }
View Full Code Here

TOP

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

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.