मैं अपने आवेदन में बीनफ़िल्ल्ड समूह का उपयोग कर कॉम्बोबॉक्स घटक बनाने की कोशिश कर रहा हूं, लेकिन फिर भी यह काम नहीं कर सकता है। मैंने पहले एक combobox बनाने की कोशिश की और build andind में इस combobox जोड़ने के बाद, लेकिन यह भी काम नहीं करता है।बीनफ़िल्ल्ड समूह?
मैं इस कोशिश कर रहा हूँ:
/** 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);
}
}
अपवाद:
/** 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
मैं यह करने के लिए कैसे?
ठीक है, मैंने संपादित किया और सवाल में अपवाद जोड़ा। – FernandoPaiva