List of usage examples for com.vaadin.ui FormLayout setData
public void setData(Object data)
From source file:local.ikram.assesment.web.SimpleFormComponent.java
private void initForm() { employeeId = new TextField("Employee Id: "); employeeId.setIcon(FontAwesome.FILE_PICTURE_O); employeeId.setRequired(true);//ww w. ja v a 2s .c o m employeeId.addValidator(new StringLengthValidator("Must be btw 7 and 9 characters", 7, 9, false)); firstName = new TextField("First Name: "); firstName.setIcon(FontAwesome.USER); firstName.setRequired(true); firstName.addValidator(new NullValidator("Cannot be empty", false)); lastName = new TextField("Last Name: "); lastName.setIcon(FontAwesome.USER); lastName.setRequired(true); lastName.addValidator(new NullValidator("Cannot be empty", false)); phoneNumber = new TextField("Phone Number: "); phoneNumber.setIcon(FontAwesome.PHONE_SQUARE); phoneNumber.setRequired(true); phoneNumber.addValidator(new NullValidator("Cannot be empty", false)); department = new TextField("Department: "); department.setIcon(FontAwesome.DESKTOP); department.setRequired(true); department.addValidator(new NullValidator("Cannot be empty", false)); saveBtn = new Button("Save", FontAwesome.SAVE); saveBtn.addStyleName("save-btn"); saveBtn.addClickListener((Button.ClickEvent e) -> { try { employeeId.validate(); firstName.validate(); lastName.validate(); phoneNumber.validate(); department.validate(); update(getEmployee()); } catch (Validator.InvalidValueException ex) { Logger.getLogger(SimpleFormComponent.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex); } }); deleteBtn = new Button("Delete", FontAwesome.RECYCLE); deleteBtn.addStyleName("delete-btn"); deleteBtn.addClickListener((Button.ClickEvent e) -> { delete(getEmployee()); }); addBtn = new Button("Add Employee", FontAwesome.PLUS_SQUARE); addBtn.addStyleName("add-btn"); addBtn.addClickListener((Button.ClickEvent e) -> { clear(); }); final HorizontalLayout buttonLayout = new HorizontalLayout(saveBtn, deleteBtn); buttonLayout.setSpacing(true); final FormLayout formLayout = new FormLayout(); formLayout.setSizeUndefined(); formLayout.setMargin(true); formLayout.setData(this); formLayout.addComponents(employeeId, firstName, lastName, phoneNumber, department, buttonLayout); setCompositionRoot(formLayout); setEmployee(new Employee()); BeanFieldGroup.bindFieldsUnbuffered(employee, this); }