setValue of Select in DefaultFieldFactory

Hello,

I have a common problem - ‘how to set the value of Select control’.

My code:
[b]

CriteriaContainer cc = ‘getcontainer from DB - 4 elements’

Select select = new Select(“My Select”);
for (int i=0; i<cc.size(); i++) {
select.addItem(cc.getEntity(i));
select.setItemCaption(cc.getEntity(i),
cc.getEntity(i).getName());
}
select.setValue(cc.getEntity(1));
[/b]

And…
When I put it on, for example, VerticalLayout, it works: it has the second element selected,

but when i try to do that inside my extension of DefaultFieldFactory - it doesn’t work
‘select’ has all of CriteriaContainers’s elements, but


select.setValue(cc.getEntity(1));
does not set the second element.

Why the behaviour is different? Maybe I should do something more?
The container in both examples is the same.

Best regards,

Tomasz