Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
ComboBox unable to set default value
Hi all, I am new to vaadin and I have the following thing that I am unable to accomplish. I have a ComboBox that is filled with JPAContainer and I want to set the default value to the first item in the station table . It looks like this:
final ComboBox station = new ComboBox("Station");
station.setWidth(COMMON_FIELD_WIDTH);
JPAContainer<Station> st = JPAContainerFactory.make(Station.class, app.PERSISTENCE_UNIT);
station.setContainerDataSource(st);
station.setNullSelectionAllowed(false);
station.setItemCaptionPropertyId("name");
station.setValue(st.firstItemId());
station.setImmediate(true);
station.requestRepaint();
My entity looks like this:
@Entity
public class Station implements Serializable {
@Id
@Column(name = "station_id") @GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer stationId;
private String code;
private String name;
@Column(name="waybill_number")
private Integer waybillNumber;
**Getter and setter**
Hi Abdullahi,
Check that your container has data, If you have checked this, check if the first item of your container is null or that the caption you choose ("name") is null. If so the behaviour it's right.
Cheers,
Javi