java - How to deal with a bean containing @Id @GeneratedVaule in Vaadin? -
I am trying to create a form that will send data to data in the calendar.
Bean Person.java is a special JavaBin:
import java.io.Serializable; Import javax.preistence.Entity; Import javax.preistence.GeneratedValue; Import javax.preistence.Id; @Entity Public Class Person Serializable {@Id @GeneratedValue Private Long ID; Private string first name; Personal string last name; Public person (long id, string first name, string last name) {this.id = id; This.firstName = firstName; This.lastName = lastName; } Public person () {} - Gators and SETTERS - The Wadine Field Group looks like this:
FieldGroup Field Group = New Beanfield Group & lt ; Person & gt; (Person.class); // From the tutorial: "We need an item data source before creating an area to find the properties, otherwise we must specify them manually" fieldGroup.setItemDataSource (new beetime & lt; person & gt; (new person 1 L, "John", "Dow"))); (Object Property Id: Field Group .getBoundPropertyIds ()) {layout.addComponent (for fieldGroup.buildAndBind (propertyId)); } There is nothing on the page, nothing is generated, no form field. Am I forgetting something? I honestly are completely new to Wadin. On the other hand, I am thinking how to deal with the ID field. It is automatically generated, so the user will not have any effect on this entry ... I am losing.
My suggestion is:
the public class expandes MyUI UI {@ Override Protected Zero Init (VaadinRequest Request) {Vertical Layout Layout = New Vertical Layout (); Field Group Field Group = New Beanfield Group & lt; Person & gt; (Person.class); FieldGroup.setItemDataSource (new BeanItem & lt; person & gt; (new person (1 L, "John", "Do"))); (For Object Properties: fieldGroup.getUnboundPropertyIds ()) {Field You should use the getUnboundPropertyIds () , because you have not banned any asset for the field before the frequency.
Comments
Post a Comment