vaadin - BeanFieldGroup create nested entities -
@entity public class document { @onetomany(mappedby="paper", cascade={cascadetype.persist, cascadetype.merge, cascadetype.refresh}) private set<documentauthor> authors; } @entity public class documentauthor { @column(name="order") @notnull private integer order; @manytoone(optional=true, cascade={cascadetype.persist, cascadetype.merge, cascadetype.refresh}) @joincolumn(name="account", columndefinition = "integer") private account account; @manytoone(optional=false, cascade={cascadetype.persist, cascadetype.merge, cascadetype.refresh}) @joincolumn(name="document", columndefinition = "integer") private document document; } @entity public class account { @onetomany(mappedby="account", cascade={cascadetype.persist, cascadetype.merge, cascadetype.refresh}) private set<documentauthor> papers; }
above entities want use beanfieldgroup. if edit/create document, want add 1 or more authors (account) , set order these. how can dynamically create these "jointable" beanfieldgroup?
viritin add-on contains many handy helpers edit kind of relations. optimal solution domain specific. if want create authors inline can use elementcollectionfield (example). if want users choose existing set of referred entities, can use multiselecttable (example) or checkboxgroup.
none of fields in viritin support ordering out of box, @ least adding simple up-down arrows should rather easy.
Comments
Post a Comment