Loading...
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.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

FormBinder nested property

michel reuteler
1 decade ago Dec 29, 2011 9:47pm
Matti Tahvonen
1 decade ago Jan 30, 2012 8:52am
Eric Leray
1 decade ago Feb 08, 2012 8:28am

Quick comment on what Matti has suggested.

We have just put in place in one of our projects the NestedProperties in combination with FormBinder and it works perfectly.
One minor detail is eventually if you want to "automate" the binding and addition of nested properties. In such as case, here is a hint on how
to proceded. Here is an automatic way to add nested properties….

BeanItem<Person> personItem = new BeanItem<Person>(this.person);
    try {
      Map<String,String> beanMap = MyBeanUtils.recursiveDescribe(person);
      for (Entry<String, String> entry : beanMap.entrySet()) {
        personItem.addItemProperty(entry.getKey(), new NestedMethodProperty(this.person, entry.getKey()));
      }
    } catch (Exception e1) {
      throw new RuntimeException("Exception not handled: " + e1, e1);
    }

where MyBeanUtils is an adapatation of the following thread http://stackoverflow.com/questions/6133660/recursive-beanutils-describe

hope this may help.

E.

Last updated on Feb, 8th 2012