Can't set the caption in Select

I’m using Vaadin 6.10 and I’m not able to set a caption in my select component.
I surely miss something,…

Here’s my code :

		Select s = new Select("Company List");
		s.addContainerProperty("caption", String.class, "");
		s.setItemCaptionPropertyId("caption");
		Object iid = s.addItem("001");
		s.getContainerProperty(iid, "caption").setValue("First company");
		iid = s.addItem("002");
		s.getContainerProperty(iid, "caption").setValue("Second company");
		iid = s.addItem("003");
		s.getContainerProperty(iid, "caption").setValue("Third company");

And I always get a null pointer exception on the 5th line (!) (s.getcontainerProperty…)

I tried also to use the setItemCaption method, but it was like it doesn’t care of it : it always displayed the ID (001.002…)

Any idea ?

That returns the actual Item added, not the Item ID. You can use

iid.getItemProperty("caption").setValue(newValue); if you want to change the property value through the item.