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.
Online