J'ai commencé récemment à utiliser le framework vaadin.Comment lier checkBox à une propriété booléenne?
J'ai un formulaire qui contient des textFields et une case à cocher, mon problème est que tous les champs sont obligatoires avec leurs propriétés attendez-vous à cocher la case ??.
C'est la forme:
public class ContactForm extends FormLayout {
private Button save = new Button("Save", this::save);
private Button delete = new Button("Delete", this::delete);
private Button cancel = new Button("Cancel", this::cancel);
private TextField firstName = new TextField("First name");
private TextField lastName = new TextField("Last name");
private TextField phone = new TextField("Phone");
private TextField email = new TextField("Email");
private DateField birthDate = new DateField("Birth date");
private CheckBox bookMarks = new CheckBox("BookMarks");
private Contact contact;
// Easily bind forms to beans and manage validation and buffering
private BeanFieldGroup<Contact> formFieldBindings;
public ContactForm() {
configureComponents();
buildLayout();
}
private void configureComponents() {...}
private void buildLayout() {...}
void edit(Contact contact) {
this.contact = contact;
if (contact != null) {
// Bind the properties of the contact POJO to fields in this form
formFieldBindings = BeanFieldGroup.bindFieldsBuffered(contact, this);
delete.setVisible(contact.getId() != null);
}
setVisible(contact != null);
}
@Override
public AddressbookUI getUI() {
return (AddressbookUI) super.getUI();
}}
Ceci est Ma classe Contact:
public class Contact implements Serializable, Cloneable {
private Long id;
private String firstName = "";
private String lastName = "";
private String phone = "";
private String email = "";
private Date birthDate;
private Boolean bookMarks;
// getters and setters
...
}
Qu'est-ce que je fais mal? Dois-je lier le champ de case à cocher manuellement?
Pour ce qui est comme je sais 'Une case à cocher avec l'état par défaut (non vérifié, false) .' – soorapadman
Recevez-vous des questions? – soorapadman
ouais, Quand je coche la case et enregistre le formulaire rien ne se passe –