Bean collection (to iterativ form) binding - best practice for Vaadin 6.8.2


does anyone know a best practice for binding a collection of complex beans into a UI form? E.g. it should be possible to bind a simple questionaire structure, Collection


  • question id
  • question text
  • Answers
+ Answer id
+ Answer text

iterative to a UI form. Obviously the data source concept/property binding can be used for single beans only, isn’t it? IMHO all Vaadin book examples are single bean based, too?

Thank you for any information.

Logically, I would say the collection of questions would normally map to a Container and each question could be represented by an Item. Then you would normally have one form per item on the page. You could have a small helper class that manages the top level questionnaire.

If you do want to have all the questions on the same form, each field needs to have its own property id. It should not be too hard to create a custom item class (perhaps inheriting PropertySetItem like BeanItem does, or even inheriting BeanItem) for your questions.

If the answers are selected from multiple options with a Vaadin selection component (e.g. OptionGroup or ComboBox), the answer alternatives for a question should be in a container - either the implicit one of the select or one you create explicitly.