Uygulamamda BeanFieldGroup kullanarak bir ComboBox bileşeni oluşturmaya çalışıyorum, ancak yine de bu işleri yapamıyorum. İlk önce bir combobox oluşturmayı denedim ve bu combobox'ı buildAndBind'e ekledikten sonra da işe yaramadı.BeanFieldGroup ile birlikte açılan kutu?
Bunu çalışıyorum:
/** person's bean */
@Entity
public class Person{
@Id
@GeneratedValue
private Integer id;
@NotNull
@NotEmpty
@Size(min=5, max=50, message="insert first name")
private String firstName;
@NotNull
@NotEmpty
@Email private String email;
//female or male
private String gender;
//get and set
}
/** app */
public class PersonView extends CustomComponent{
private final BeanFieldGroup<Person> binder = new BeanFieldGroup<Person>(Person.class);
private Person bean = new Person();
private ComboBox gender;
public PersonView(){
VerticalLayout vLayout = new VerticalLayout();
Field<?> field = null;
field = binder.buildAndBind("Gender", "gender", ComboBox.class);
gender = (ComboBox)binder.getField("gender");
gender.addItem("Male");
gender.addItem("Female");
vLayout.addComponent(gender);
}
}
İstisna: Bunu nasıl
/** exception /*
Caused by: com.vaadin.data.fieldgroup.FieldGroup$BindException: Unable to build a field of type com.vaadin.ui.ComboBox for editing java.lang.String
at com.vaadin.data.fieldgroup.FieldGroup.build(FieldGroup.java:1067)
at com.vaadin.data.fieldgroup.FieldGroup.buildAndBind(FieldGroup.java:1039)
at br.ind.ibg.views.CurriculumView.buildLayout(CurriculumView.java:50)
at br.ind.ibg.views.CurriculumView.<init>(CurriculumView.java:32)
at br.ind.ibg.views.LoginView.buttonClick(LoginView.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:508)
... 37 more
?
tamam, söz konusu istisnayı düzenledim ve ekledim. – FernandoPaiva