Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Form reset?
Is it possible after commit a form reset this fields with one command?
discard () it does not seem to be the correct statement.
HorizontalLayout buttons = new HorizontalLayout();
Button apply = new Button("speichern", new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
try {
[b] personForm.commit();
personForm.discard(); //not work![/b]
} catch (Exception e) {
// Ignored, we'll let the Form handle the errors
}
}
});
Try with setValue(null); or setValue(""); in the form's fields... I think that personForm.getField(fieldID).setValue(""); can work.
William Giovanni Valencia Acosta: Try with setValue(null); or setValue(""); in the form's fields... I think that personForm.getField(fieldID).setValue(""); can work.
I have tried in this way but the validator for the fields generated an error. I can not enter new values.
try {
personForm.commit(); //Commit
Anlegen(personForm); //write the Data to DB
clearForm(); //clear the Form with form.setWert("");
//after this i can not enter new values ... :(
} catch (Exception e) {
Michael Froherz:
William Giovanni Valencia Acosta: Try with setValue(null); or setValue(""); in the form's fields... I think that personForm.getField(fieldID).setValue(""); can work.
I have tried in this way but the validator for the fields generated an error. I can not enter new values.
try { personForm.commit(); //Commit Anlegen(personForm); //write the Data to DB clearForm(); //clear the Form with form.setWert(""); //after this i can not enter new values ... :( } catch (Exception e) {
If you use personForm=new Form(); after the clearForm()?
no, personForm is a component of the constructors.
For example:
public class anything extends VerticalLayout {
public anything() {
klient = new Klient(); // a person POJO
BeanItem<Klient> personItem = new BeanItem<Klient>(klient); // item from
// POJO
/*
* Form
*/
final Form personForm = new Form();
// Enable buffering.
personForm.setWriteThrough(false);
....
clearForm is called after the commit from the form.