ReadOnly field in FieldGroup

I just want setReadOnly TextField (for example) in FieldGroup, but the TexField not assume the property read only.
My code:
form = new FormLayout();
fieldGroup = new BeanFieldGroup(User.class);
txtName = new TextField(“Nome”);
form.addComponent(txtName);
fieldGroup.bind(txtName, User.PROPERTY_NAME);
fieldGroup.setBuffered(true);
txtName.setReadOnly(true);

Someone help me, please?

Hi,
I created the following minimal Vaadin UI to try to reproduce the problem you are experiencing:

[code]
@Theme(“mytheme”)
@Widgetset(“com.example.myapplication.MyAppWidgetset”)
public class MyUI extends UI {

private FormLayout form;
private BeanFieldGroup<User> fieldGroup;
private TextField txtName;

public class User {

    static final String PROPERTY_NAME = "name";
    
    String name;
}

@Override
protected void init(VaadinRequest vaadinRequest) {
    form = new FormLayout();
    fieldGroup = new BeanFieldGroup<User>(User.class);
    txtName = new TextField("Name");
    form.addComponent(txtName);
    fieldGroup.bind(txtName, User.PROPERTY_NAME);
    fieldGroup.setBuffered(true);
    txtName.setReadOnly(true);
    
    setContent(form);
}

@WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true)
@VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
public static class MyUIServlet extends VaadinServlet {
}

}
[/code]But I could not reproduce the problem. The TextField is in read only mode in the UI. Maybe I misunderstood your problem?

Jonni, You are right. My mistake.
I had a fieldgroup.setItemDataSource after instanciate my object with new BeanFieldGroup(User.class);

Thanks for the reply. Sorry for my silliness.