Where is getField with FormLayout?

Prior to Vaadin 7 there was such a thing as a Form that has now been deprecated. When using the Form one could add several text fields and recover a text field by name. For instance suppose a Form is created and a text field is added with a name of “Company”

form.addField(new textField(“Company”))

later that field could be recovered with form.getField(“Company”), which was great. However, now that “Form” has been deprecated in Vaadin 7 where does this functionality live now? I tried to look at “FormLayout” as the solution, but I only see where you can recover a component by it’s ID and not by it’s name.

It’s in the FieldGroup.

I had looked at FieldGroup before, but I don’t care to bind a property to a textField. I simply want to getField by the caption of the textField. Here is some sample code I started playing with. In the button click part I was trying to do something like formLayout.getField(“First Name”), but it doesn’t recognize this.

package com.example.fieldgroups;

import java.util.Collection;

import javax.servlet.annotation.WebServlet;

import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.data.fieldgroup.FieldGroup;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.TextField;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;

public class FieldgroupsUI extends UI {

@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = FieldgroupsUI.class)
public static class Servlet extends VaadinServlet {

FormLayout formLayout = new FormLayout();
TextField firstName = new TextField("First Name");
TextField lastName  = new TextField("Last Name");
Label label = new Label("Thank you for clicking");

protected void init(VaadinRequest request) {
    final VerticalLayout layout = new VerticalLayout();
    formLayout.setCaption("FieldGroup Example");
    final FieldGroup fieldGroup = new FieldGroup();
    Button button = new Button("Click Me");
    button.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            //formLayout.addComponent(new Label("Thank you for clicking"));
            for (Object row: fieldGroup.getBoundPropertyIds()) {
                label.setValue(label.getValue() + " " + row);



The feature you are using is definitely not something the Form was designed to do (It was designed to bind properties, just like FieldGroup); the fact that it works is just because of a default behavious design desicion. It might be that the same thing works with FieldGroups too, but it would be a strange combination of default values, behaviour, and unsupported features if it did. If you need the functionality you describe, you can easily create your own Map implementation for it which does the same thing, without using unsupported API to do it.