Examples of addValidator()


Examples of com.vaadin.ui.TextField.addValidator()

public class TestReadOnlyValidation {

    @Test
    public void testIntegerValidation() {
        TextField field = new TextField();
        field.addValidator(new IntegerValidator("Enter a Valid Number"));
        field.setValue(String.valueOf(10));
        field.validate();
    }
}
View Full Code Here

Examples of com.vaadin.ui.TextField.addValidator()

                + ". {0} is not.";
        IntegerRangeValidator validator = new IntegerRangeValidator(
                errorMessage, min, max);
        fieldWithError.setValue("142");

        fieldWithError.addValidator(validator);
        fieldWithError.setConverter(Integer.class);
        fieldWithError.setImmediate(true);

        TextField fieldWithoutError = new TextField();
        fieldWithoutError.addValidator(validator);
View Full Code Here

Examples of com.vaadin.ui.TextField.addValidator()

        fieldWithError.addValidator(validator);
        fieldWithError.setConverter(Integer.class);
        fieldWithError.setImmediate(true);

        TextField fieldWithoutError = new TextField();
        fieldWithoutError.addValidator(validator);
        fieldWithoutError.setConverter(Integer.class);
        fieldWithoutError.setValue("42");
        addComponent(fieldWithError);
        addComponent(fieldWithoutError);
    }
View Full Code Here

Examples of com.vaadin.ui.TextField.addValidator()

        form.setValidationVisible(true);
        form.setCaption("This is a form");
        form.setDescription("How do you do?");
        final TextField field1 = new TextField("Write here");
        field1.setImmediate(true);
        field1.addValidator(new Validator() {

            @Override
            public void validate(Object value) throws InvalidValueException {
                if (!isValid(value)) {
                    throw new InvalidValueException("FAIL!");
View Full Code Here

Examples of com.vaadin.ui.TextField.addValidator()

        listOfAllFields.add(tf2);

        TextField tf3 = new TextField(
                "Text field with required=true and strlen >= 3");
        tf3.setRequired(true);
        tf3.addValidator(strLenValidator);
        listOfAllFields.add(tf3);

        TextField tf4 = new TextField(
                "Text field with required=false (default) and strlen >= 3");
        tf4.addValidator(strLenValidator);
View Full Code Here

Examples of com.vaadin.ui.TextField.addValidator()

        tf3.addValidator(strLenValidator);
        listOfAllFields.add(tf3);

        TextField tf4 = new TextField(
                "Text field with required=false (default) and strlen >= 3");
        tf4.addValidator(strLenValidator);
        listOfAllFields.add(tf4);

        for (Iterator<TextField> i = listOfAllFields.iterator(); i.hasNext();) {
            TextField tf = i.next();
            main.addComponent(tf);
View Full Code Here

Examples of com.vaadin.ui.TextField.addValidator()

            @Override
            protected boolean isValidValue(String value) {
                return value.matches("[1-9][0-9]{4}");
            }
        };
        tf.addValidator(postalCodeValidator);
        tf.setValue("12345");
        form.addField("k", tf);

        Button b = new Button("Commit", new ClickListener() {
View Full Code Here

Examples of com.vaadin.ui.TextField.addValidator()

        final Form form = new Form(new VerticalLayout());

        // simple validators

        TextField tf = new TextField("A field, must contain 1-2 chars");
        tf.addValidator(new StringLengthValidator("Invalid length", 1, 2, false));
        tf.setRequired(true);
        tf.setValue("ab");
        form.addField("a", tf);

        tf = new TextField("A field, must contain an integer");
View Full Code Here

Examples of com.vaadin.ui.TextField.addValidator()

        tf.setRequired(true);
        tf.setValue("ab");
        form.addField("a", tf);

        tf = new TextField("A field, must contain an integer");
        tf.addValidator(new IntegerValidator("Invalid integer {0}"));
        tf.setRequired(true);
        tf.setValue("123");
        form.addField("b", tf);

        tf = new TextField("A field, must contain an integer or be empty");
View Full Code Here

Examples of com.vaadin.ui.TextField.addValidator()

        tf.setRequired(true);
        tf.setValue("123");
        form.addField("b", tf);

        tf = new TextField("A field, must contain an integer or be empty");
        tf.addValidator(new IntegerValidator("Invalid integer {0}"));
        tf.setValue("-321");
        form.addField("c", tf);

        tf = new TextField(
                "A field, must contain a floating point number or be empty");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.