Directory

← Back

CustomField

A form field whose presentation and logic can be customized

Author

Rating

Popularity

<100

Custom fields offer the possibility to create Vaadin form fields with customized presentation and logic.

Fields can be composed of standard or custom Vaadin components on the server side. The field logic can either be reused directly for the CustomField or partly overridden for customized behavior.

This also allows the creation of custom editors for sub-objects on forms, including nesting of forms in CustomFields within other forms.

Sample code

    public static class BooleanField extends CustomField {

        public BooleanField() {
            VerticalLayout layout = new VerticalLayout();

            layout.addComponent(new Label("Please click the button"));

            final Button button = new Button("Click me");
            button.addListener(new ClickListener() {
                public void buttonClick(ClickEvent event) {
                    Object value = getValue();
                    boolean newValue = true;
                    if ((value instanceof Boolean) && ((Boolean) value)) {
                        newValue = false;
                    }
                    setValue(newValue);
                    button.setCaption(newValue ? "On" : "Off");
                }
            });
            layout.addComponent(button);

            setCompositionRoot(layout);
        }

        @Override
        public Class<?> getType() {
            return Boolean.class;
        }
    }

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Custom field add-on split into this core add-on (stable) and a separate CustomField Utils add-on.

Released
2012-04-10
Maturity
CERTIFIED
License
Apache License 2.0

Compatibility

Framework
Vaadin 6.0+
Vaadin 6.5+ in 0.9.4
Vaadin 6.2+ in 0.5
Browser
Browser Independent

CustomField - Vaadin Add-on Directory

A form field whose presentation and logic can be customized CustomField - Vaadin Add-on Directory
Custom fields offer the possibility to create Vaadin form fields with customized presentation and logic. Fields can be composed of standard or custom Vaadin components on the server side. The field logic can either be reused directly for the CustomField or partly overridden for customized behavior. This also allows the creation of custom editors for sub-objects on forms, including nesting of forms in CustomFields within other forms.
Forum post
Source code repository
Online Demo

CustomField version 0.5
null

CustomField version 0.7
FieldWrapper for easier wrapping of a Field with a customized layout around it, value conversions etc. Many new examples (wrapped fields and conversions, nested forms, nested forms with fields in parent form layout, ...).

CustomField version 0.7.1
Validation improvements

CustomField version 0.7.2
Validation fixes

CustomField version 0.7.3
Improved validation error display and empty value handling defaults, can be overridden

CustomField version 0.8.0
PropertyConverter moved to org.vaadin.customfield, new helper/wrapper class ConvertingValidator

CustomField version 0.8.1
Buffered operations always delegated to the field

CustomField version 0.8.2
Better handling of read-through and write-through modes

CustomField version 0.9.0
Package name changes (now org.vaadin.addon.customfield.*) breaking backwards compatibility. New helper classes (field wrappers) for converting between beans and their identifiers, or sets of such.

CustomField version 0.9.1
Reuse old collection in BeanSetFieldPropertyConverter (needed e.g. for lazy JPA collections).

CustomField version 0.9.2
Better handling of collections in BeanSetFieldPropertyConverter for JPA

CustomField version 0.9.3
Added getValidator() API to ConvertingValidator

CustomField version 0.9.4
Minor change in BeanSetFieldPropertyConverter to better support removing items from a set when using JPAContainer with Hibernate.

CustomField version 1.0.0
Custom field add-on split into this core add-on (stable) and a separate CustomField Utils add-on.

Online