Select setItemCaption not working correctly ?

Hi,

I’m trying to get Id / Value couple of in a combo box. However the following code display the ID and never the caption :


	// Create a selection component
		Select select = new Select ("Select something here");
		select.setItemCaptionMode(Select.ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID);
		// Add some items and give each an item ID
		Object itemId = select.addItem("1");
		System.out.println("itemId : " + itemId);
		select.setItemCaption(itemId, "libelle_1");
		itemId = select.addItem(new Integer("2"));
		select.setItemCaption(itemId, "libelle_2");
		itemId = select.addItem(new Integer("3"));
		select.setItemCaption(itemId, "libelle_3");
		select.setImmediate(true);
		mainView.addComponent(select);
		select.addListener(this);

Is this normal ?

Regards,
Denis.

Hi,

Object itemId = select.addItem("1"); // this returns an Item not an itemId (you specify the item id)
select.setItemCaption(itemId, "libelle_1"); // itemId here is actually an Item instance, change itemId to "1"

Best Regards,
Marc

Thanks