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 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