【发布时间】:2014-10-09 06:48:32
【问题描述】:
我正在尝试制作一个将数据发送到 Vaadin 数据库的表单。
Bean Person.java 是一个典型的JavaBean:
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@Entity
public class Person implements Serializable {
@Id
@GeneratedValue
private Long id;
private String firstName;
private String lastName;
public Person(Long id, String firstName, String lastName) {
this.id = id;
this.firstName = firstName;
this.lastName = lastName;
}
public Person() {
}
-- getters and setters --
Vaadin FieldGroup 如下所示:
FieldGroup fieldGroup = new BeanFieldGroup<Person>(Person.class);
// from the tutorial: "We need an item data source before we create the fields to be able to
// find the properties, otherwise we have to specify them by hand"
fieldGroup.setItemDataSource(new BeanItem<Person>(new Person(1L,
"John", "Doe")));
for (Object propertyId : fieldGroup.getBoundPropertyIds()) {
layout.addComponent(fieldGroup.buildAndBind(propertyId));
}
页面上什么都没有。什么都没有生成,没有表单域。我错过了什么吗?老实说,我对 Vaadin 完全陌生。另一方面,我想知道如何处理 ID 字段。它是自动生成的,所以用户对这个值没有任何影响......我迷路了。
【问题讨论】:
标签: java database jpa vaadin vaadin7