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?
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
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
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();
}
super.setText(caption);
}
};
}
}
@Connect(MyComboBox.class)
public class MyComboBoxConnector extends ComboBoxConnector {
@Override public MyFilterSelect getWidget() {
return (MyFilterSelect)super.getWidget();
}
}