Package com.vaadin.data.validator

Examples of com.vaadin.data.validator.BeanValidator


    }

    @Test
    public void testBeanValidationsException_TwoValidationErrors() {
        InvalidValueException[] causes = null;
        BeanValidator validator = new BeanValidator(BeanToValidate.class,
                "nickname");
        try {
            validator.validate("A");
        } catch (InvalidValueException e) {
            causes = e.getCauses();
        }

        Assert.assertEquals(2, causes.length);
View Full Code Here


        TextField firstName = new TextField("First name",
                item.getItemProperty("name"));
        firstName.setImmediate(true);
        setContent(firstName);

        firstName.addValidator(new BeanValidator(Person.class, "name"));
    }
View Full Code Here

    private void buildForm() {
        fieldGroup = new PersistenceFieldGroup(beanItem);
        fieldGroup.setFieldFactory(new PersistenceFieldGroupFieldFactory());
       
        formLayout.addComponent(nimField = fieldGroup.buildAndBind("NIM", "NIM"));
        nimField.addValidator(new BeanValidator(Mahasiswa.class, "NIM"));
        ((TextField) nimField).setNullRepresentation("");
        ((TextField) nimField).setInputPrompt("9 digit Nomor Induk Mahasiswa");

        formLayout.addComponent(namaField = fieldGroup.buildAndBind("Nama Lengkap", "nama"));
        namaField.addValidator(new BeanValidator(Mahasiswa.class, "nama"));
        ((TextField) namaField).setNullRepresentation("");

        formLayout.addComponent(tanggalLField = fieldGroup.buildAndBind("Tanggal Lahir", "tanggalLahir"));
        tanggalLField.addValidator(new BeanValidator(Mahasiswa.class, "tanggalLahir"));

        formLayout.addComponent(sksField = fieldGroup.buildAndBind("SKS", "sks"));
        sksField.addValidator(new BeanValidator(Mahasiswa.class, "sks"));
        ((TextField) sksField).setNullRepresentation("");

        formLayout.addComponent(activeField = fieldGroup.buildAndBind("Aktif", "active"));
        activeField.addValidator(new BeanValidator(Mahasiswa.class, "active"));
       
        formLayout.addComponent(dosenPembimbingField = fieldGroup.buildAndBind("Dosen Pembimbing", "dosenPembimbing"));
       
        PopupView view = new PopupView(new PopupView.Content() {
                @Override
View Full Code Here

    @Override
    public void unbind(Field<?> field) throws BindException {
        super.unbind(field);

        BeanValidator removed = defaultValidators.remove(field);
        if (removed != null) {
            field.removeValidator(removed);
        }
    }
View Full Code Here

    protected void configureField(Field<?> field) {
        super.configureField(field);
        // Add Bean validators if there are annotations
        if (isBeanValidationImplementationAvailable()
                && !defaultValidators.containsKey(field)) {
            BeanValidator validator = new BeanValidator(beanType,
                    getPropertyId(field).toString());
            field.addValidator(validator);
            if (field.getLocale() != null) {
                validator.setLocale(field.getLocale());
            }
            defaultValidators.put(field, validator);
        }
    }
View Full Code Here

    @Override
    protected void configureField(Field<?> field) {
        super.configureField(field);
        // Add Bean validators if there are annotations
        if (isBeanValidationImplementationAvailable()) {
            BeanValidator validator = new BeanValidator(beanType,
                    getPropertyId(field).toString());
            field.addValidator(validator);
            if (field.getLocale() != null) {
                validator.setLocale(field.getLocale());
            }
        }
    }
View Full Code Here

TOP

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

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.