Add-on Directory

← Back

Multicombobox Component

Multi ComboBox for Vaadin Flow

Author

Rating

Popularity

300+

Description

The Multicombobox component provides support to select multiple items for a dropdown.

It's optimized to be used with a keyboard:

  • Filtering selects the first non-selected item
  • Enter toggles the selection
  • Arrow up/down to navigate to the next/previous item.

"Select All" selects all the items.

"Cancel" closes and resets the selection (replace the current value with the value when the user opened the combobox)

It's recommended to use the page size to activate the filtering on client side.

Usage

Create a new component MultiComboBox and use it like a ComboBox. The API is quite similar.

The value returned is a Set of beans.

Limitations

  • Custom value does not work, you can't add value that are not in the list.
  • This add-on implements HasHelper, so it requires Vaadin 14.4+.

Examples

Basic example

    public SimpleView() {
        MultiComboBox<Person> combobox = new MultiComboBox<>();
        combobox.setLabel("Persons");
        List<Person> personList = getItems();
        combobox.setItems(personList);
        add(combobox);
    }

    private List<Person> getItems() {
        PersonService personService = new PersonService();
        return personService.fetchAll();
    }

Item label Generator

    public LabelGeneratorView() {
        List<Person> personList = getItems();
        MultiComboBox<Person> combobox = new MultiComboBox<>();
        combobox.setLabel("Persons Phone");
        combobox.setItemLabelGenerator(person -> {
            if (person.getEmail() != null) {
                return person.getPhoneNumber();
            } else {
                return "No phone for " + person.getId();
            }
        });
        combobox.setItems(personList);
        add(combobox);
    }

    private List<Person> getItems() {
        PersonService personService = new PersonService();
        return personService.fetchAll();
    }

Client side filtering

You can set a page size > your list size to enable the filtering on the client side.


    private Span itemsSelected = new Span();

    public InMemoryView() {
        MultiComboBox<Person> combobox = new MultiComboBox<>(1000);
        combobox.setLabel("Persons");
        List<Person> personList = getItems();
        combobox.setItems(personList);
        add(combobox);

        HashSet<Person> value = new HashSet<>();
        value.add(personList.get(0));
        value.add(personList.get(5));
        combobox.setValue(value);
        combobox.addValueChangeListener(e -> {
            if (e.getValue() != null) {
                itemsSelected.setText("Items selected:" + e.getValue().toString());
            } else {
                itemsSelected.setText("No item selected");
            }

        });
    }

    private List<Person> getItems() {
        PersonService personService = new PersonService();
        return personService.fetchAll();
    }

Binding and validation

    private BackendBean backendBean = new BackendBean();
    private Binder<BackendBean> binder = new Binder<>();

    public BindingView() {

        MultiComboBox<Person> combobox = new MultiComboBox<>();
        combobox.setLabel("Persons");
        List<Person> personList = getItems();
        combobox.setItems(personList);
        HashSet<Person> value = new HashSet<>();
        value.add(personList.get(0));
        value.add(personList.get(5));
        backendBean.setPersons(value);
        add(combobox);
        binder.setBean(backendBean);
        binder.forField(combobox).asRequired().withValidator(val -> {
            return (val != null) && (val.size() == 2);
        }, "You have to select exactly 2 persons")
            .bind(BackendBean::getPersons,BackendBean::setPersons);
    }

    private List<Person> getItems() {
        PersonService personService = new PersonService();
        return personService.fetchAll();
    }

    public static class BackendBean {
        private Set<Person> persons;

        public Set<Person> getPersons() {
            return persons;
        }

        public void setPersons(Set<Person> persons) {
            this.persons = persons;
        }
    }

Demo

You can check the demo here: https://incubator.app.fi/multi-combo-box-flow-demo/

Missing features or bugs

You can report any issue or missing feature on github: https://github.com/vaadin-component-factory/multiselect-combo-box

Sponsored development

Major pieces of development of this add-on has been sponsored by customers of Vaadin. Read more about Expert on Demand at: Support and Pricing

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

Update web component version to 0.5.1. Fix focus on filtering.

Released
2022-11-25
Maturity
EXPERIMENTAL
License
Apache License 2.0

Compatibility

Framework
Vaadin 14
Vaadin 23 in 23.1.2
Browser
N/A

Image Crop Add-on - Vaadin Add-on Directory

Image Crop Add-on for Vaadin Flow Image Crop Add-on - Vaadin Add-on Directory
Component for cropping images. Wrapper for React component [react-image-crop](https://www.npmjs.com/package/react-image-crop). #### Features The component allows to crop images and configure the following properties for a customized crop: * crop dimensions (unit, x and y coordinates, width, and height) * aspect ratio (for example, 1 for a square or 16/9 for landscape) * circular crop (selection are has circular shape) * keep selection (selection can't be disabled if the user clicks outside the selection area) * disabled (cannot resize or draw a new crop) * locked (cannot create or resize a crop, but can still drag the existing crop around) * min width (minimum crop width) * min height (minimum crop height) * max width (maximum crop width) * max height (maximum crop height) * rule of thirds (to show rule of thirds lines in the cropped area) The cropped image result can be obtain as a URI using `getCroppedImageDataUri` method or as a Base64 encoded byte array by using `getCroppedImageBase64` method. #### Found a bug or have a suggestion? Report it on GitHub For bug reports, feature suggestions, or questions, please open an issue on [GitHub](https://github.com/FlowingCode/ImageCrop/issues). This makes it easier for us to track and respond efficiently, ensuring you get the best possible support. Your input helps us improve—thank you!
Author Homepage
Online Demo
Issue tracker
View on GitHub

Image Crop Add-on version 1.0.0
Initial release

Image Crop Add-on version 1.1.0
#### New features: * Add method to set full height to image ([#5](https://github.com/FlowingCode/ImageCrop/issues/5))

Image Crop Add-on version 1.1.1
#### Bug fixes: * Update canvas size to avoid white space on result ([#7](https://github.com/FlowingCode/ImageCrop/issues/7))

Online