Example usage for com.vaadin.ui AbstractField getComponentError

List of usage examples for com.vaadin.ui AbstractField getComponentError

Introduction

In this page you can find the example usage for com.vaadin.ui AbstractField getComponentError.

Prototype

public ErrorMessage getComponentError() 

Source Link

Document

Gets the component's error message.

Usage

From source file:nz.co.senanque.vaadinsupport.application.MaduraSessionManager.java

License:Apache License

public void bind(final MaduraForm form, final AbstractField field, MaduraPropertyWrapper property) {
    field.setPropertyDataSource(property);
    Hints hints = getHints();//from w ww.j a va  2  s.  c  om

    hints.setCommonProperties(field, property, m_messageSource);
    setPermissions(property, field);
    registerWidget(field);
    field.addListener(new MaduraPropertyWrapper.ValueChangeListener() {

        private static final long serialVersionUID = -3295559168401789196L;

        public void valueChange(ValueChangeEvent event) {
            com.vaadin.data.Property p = field.getPropertyDataSource();
            if (p instanceof MaduraPropertyWrapper) {
                MaduraPropertyWrapper property = (MaduraPropertyWrapper) p;
                if (property.getErrorText() != null) {
                    field.setComponentError(new UserError(property.getErrorText()));
                } else {
                    field.setComponentError(null);
                }
            }
            List<String> errors = new ArrayList<String>();
            if (form != null) {
                for (Object propertyId : form.getItemPropertyIds()) {
                    Field f = form.getField(propertyId);
                    if (f instanceof AbstractField) {
                        AbstractField fieldy = (AbstractField) f;
                        if (fieldy.getComponentError() != null) {
                            errors.add(fieldy.getComponentError().toString());
                        }
                    }
                }
                form.setErrors(errors);
            }
            updateOtherFields(field);
        }
    });
}