ComboBox items with custom caption

I am trying to create a ComboBox where the caption for each item is a combination of properties, like object.title +
The items that are added to the ComboBox are returned from a backend query wrapped in BeanItem (using LazyQueryContainer).
Is there a way I can set the captions for individual items?

I tried by setting the item caption mode to ITEM_CAPTION_MODE_EXPLICIT and doing comboBox.setItemCaption in the ItemSetChangeListener on both the ComboBox and the Container but that doesn’t seem to work
How do I do this? Appreciate any help, thanks.


I managed to solve this problem in the following way.

UserContainer is of type BeanItemContainer.

            cboxUser = new ComboBox(AppData.getMessage("user"));
	cboxUser.addListener(new ItemSetChangeListener() {
		public void containerItemSetChange(ItemSetChangeEvent event) {
			UserContainer container = (UserContainer)((ComboBox)event.getContainer()).getContainerDataSource();
			Collection<UserVO> users = container.getItemIds();
			for (Iterator iterator = users.iterator(); iterator.hasNext();) {
				UserVO user = (UserVO);
				cboxUser.setItemCaption(user, user.getFirstName() + " " + user.getName());

I hope the example is explicit enough.

if yet need solve…

public class MyContainer implements Serializable {

    private Long id;
    private Long name;


    public String toString() {
        return getName() + " " + getId();

ComboBox cb = new ComboBox(“Caption”, myContainer);

Hi, is it posible to use html as the item caption for comboBox ?

How can I develope a right to left supported web site in vaadin?

Thank you , now it has served me very helpful / Muchas Gracias, hoy me ha servido de mucha ayuda!!!