ComboBox different text in the title and in the items list

Dear friends,

I want to setup a ComboBox component that contains a list of companies. But in the title, I want to show just the company name and in the list of the companies, I want to provide some additional hints like City. Is this possible in ComboBox?

To illustrate this:

[font=courier new]
Company Ltd. <>

| Company Ltd (London) |

Company 2 Ltd (Paris)


You can use a GeneratedPropertyContainer and then set itemCaptionPropertyId in combobox

BeanItemContainer<Company> container = ...
GeneratedPropertyContainer gp = new GeneratedPropertyContainer(container);
gp.addGeneratedProperty("captionProperty", new PropertyValueGenerator<String>() {
    public String getValue(Item item, Object itemId, Object propertyId) {
        return buildCaption( (Company)itemId );

    private String buildCaption(Company c) {
        return String.format("%s (%s)", c.getName(), c.getCity());
    public Class<String> getType() { return String.class; }

ComboBox comboBox = new ComboBox("", gp);

Thank you, I was able to figure out how to display a custom property. But the problem is that it shows the same text in both text field and drop down list - I want to show a different text in the text field and different in the drop down list (as hints hints). This is probably not possible in Vaadin, but I’m rather asking whether there is some way how to do it :slight_smile:

Sorry, completely misunderstood your question.
A very dirty way to reach your goal could be to have a custom ComboBox connected to a VFilterSelect extension with a custom TextBox; in TextBox.setText method you can modify the caption shown for selected item.
Not really a good solution by the way :wink:

Server side

public class MyComboBox extends ComboBox {
   // add constructors

Client side

public class MyFilterSelect extends VFilterSelect {
    @Override protected TextBox createTextBox() {
        return new FilterSelectTextBox() {
            @Override public void setText(String text) {
                String caption = text;
                if (caption != null) {
                    caption = caption.substring(0, caption.indexOf('(')).trim();
public class MyComboBoxConnector extends ComboBoxConnector {
    @Override public MyFilterSelect getWidget() {
        return (MyFilterSelect)super.getWidget();