When form properties are propagated to the bean?

Hi all,

I’m new in vaadin. I have a question about bean bindin in form.

I have a simple form with ItemDataSource.

EmailBean emailBean = new EmailBean();
BeanItem<EmailBean> item = new BeanItem<EmailBean>(emailBean);

As i understud, the values from the browser are propagated to the DataSource after form.commit(). So the emailBean should be filled with the values from the browser form after commit called.

What i want is use this emailBean instance after commit for my busines code. Actually i want to send an email with date entered in the form. The commit is called with button listener. Directly after commit, in the listener method, is the bean still empty. Have i unterstand the concept wrong?

What event or similar (that is fired after commit) should i use? I could read the values directly from the TextFields objects, but to get them directly from the bean seems the right way for me.

thanks for advise

You have understood the concept, yes. This sounds more like a bug in your code; have you bound the individual form fields to the form itself? Are you using Vaadin 6 or 7?

I use vaadin 6.

here ist the code:
form = new Form();
form.setDescription(“You can try to send an email to address you want.”);

emailBean = new EmailBean();
BeanItem<EmailBean> item = new BeanItem<EmailBean>(emailBean);
item.addListener(new Item.PropertySetChangeListener() {
  public void itemPropertySetChange(Item.PropertySetChangeEvent event) {
    try {
      sendStatus.setValue("Sending war successful.");
    } catch (Exception e) {
      sendStatus.setValue("Sending failed."+e.getMessage());

final TextField toAddressField = new TextField("Send to:");
toAddressField.setWidth(200, UNITS_PIXELS);
toAddressField.setRequiredError("address needed.");
toAddressField.addValidator(new EmailValidator("Not valid email address entered."));
form.addField("toAddress", toAddressField);

TextField subjectField = new TextField("Subject:");
subjectField.setWidth(200, UNITS_PIXELS);
form.addField("subject", subjectField);

TextArea contentArea = new TextArea("Content:");
contentArea.setWidth(200, UNITS_PIXELS);
contentArea.setHeight(100, UNITS_PIXELS);
form.addField("content", contentArea);

HorizontalLayout okbar = new HorizontalLayout();

Button okbutton = new Button("Send");
okbutton.addListener(new Button.ClickListener() {
  public void buttonClick(Button.ClickEvent event) {
    try {
      if (!form.isValid()) {
      } else {
    } catch (Validator.EmptyValueException e) {
      // prevent propagate exception

sendStatus = new Label("Sending war successful.");
okbar.addComponent(new Label(" ", Label.CONTENT_XHTML));



and the bean

private class EmailBean {
String subject;
String content;
String toAddress;

private String getSubject() {
  return subject;

private void setSubject(String subject) {
  this.subject = subject;

private String getContent() {
  return content;

private void setContent(String content) {
  this.content = content;

private String getToAddress() {
  return toAddress;

private void setToAddress(String toAddress) {
  this.toAddress = toAddress;


Personally, I would put the code from PropSetChange into the button listener, after commit(). Other then that, I can’t really find anything strange; are you sure that commit is called, and doesn’t throw exceptions?

I have found the problem. It was as so often in front of the monitor.

My bean class was private and all it’s getters/setters were also private…

Now it works…