Vaadin + grails simple application for form submission not saving data

Hi Guys,

I’m new to Vaadin, as a part of some POC for my organisation i decided to use Data Model backend up by Grails and UI is completely in Vaadin. I’ve gone through several online resources for form fieldgroup binding and then using binder.commit to save data. But i see new bean data is not getting persisted.

Sample:
def buildForm() {
BeanFieldGroup binder = new BeanFieldGroup(Student.class);

    Panel form = new Panel("Buffered Form");
    FormLayout formLayout = new FormLayout();
    form.setContent(formLayout);

    binder.setItemDataSource(new BeanItem<Student>(new Student()));

    TextField firstName = binder.buildAndBind("First Name", "firstName")
    TextField middleName =binder.buildAndBind("Middle Name", "middleName")
    TextField lastName =binder.buildAndBind("Last Name", "lastName")
    TextField fatherName =binder.buildAndBind("Father Name", "fatherName")
    TextField motherName =binder.buildAndBind("Mother Name", "motherName")

    firstName.setNullRepresentation("")
    middleName.setNullRepresentation("")
    lastName.setNullRepresentation("")
    fatherName.setNullRepresentation("")
    motherName.setNullRepresentation("")

    def constraints = Student.constraints

    firstName.addValidator(new StringLengthValidator("Validation failed", constraints.firstName.minSize, constraints.firstName.maxSize, constraints.firstName.blank));
    lastName.addValidator(new StringLengthValidator("Validation failed", constraints.lastName.minSize, constraints.lastName.maxSize,constraints.lastName.blank));
    fatherName.addValidator(new StringLengthValidator("Validation failed", constraints.fatherName.minSize, constraints.fatherName.maxSize,constraints.fatherName.blank));
    motherName.addValidator(new StringLengthValidator("Validation failed", constraints.motherName.minSize, constraints.motherName.maxSize,constraints.motherName.blank));


    formLayout.addComponent(firstName)
    formLayout.addComponent(middleName)
    formLayout.addComponent(lastName)
    formLayout.addComponent(fatherName)
    formLayout.addComponent(motherName)

    // Enable buffering (actually enabled by default)
    binder.setBuffered(true);

    // A button to commit the buffer
    formLayout.addComponent(new Button("Save", new Button.ClickListener(){
        private static final long serialVersionUID = 2928773509123270489L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {

                //println(binder.buffered)

                binder.commit();
                Notification.show("Saved!");
            } catch (FieldGroup.CommitException e) {
                Notification.show("You fail!");
            }
        }
    }));

    // A button to discard the buffer
    formLayout.addComponent(new Button("Cancel", new Button.ClickListener() {
        private static final long serialVersionUID = 2928773509123270489L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            binder.discard();
            Notification.show("Discarded!");
        }
    }));



Please help.

Thanks,
Nukul

In addition,

I can also call a Grails Service method say to addNewStudent, but then what is real purpose of binder.commit() ?