Hiding a bean property

Hello!
I currently try to use the automatic form creation more frequently than in the past. During some testing I came accross a question whre I hope someone can help.
For example I have the following class:


public class Person {
 private int pid;
 private String surname;
private String firstname;

private Person() {}

// getters and setters
}

Form this object I want to create a form,which looks the following way:


// Create an instance of the bean
Person bean = new Person();
        
// Wrap it in a BeanItem
BeanItem<Person> item = new BeanItem<Person>(bean);
        
// Bind it to a component
Form form = new Form();
form.setItemDataSource(item);

So far so good, the form displays three textfields, one for the pid, one for the surname and one for the firstname. But however I want to hide the pid from the end users, therefor the pid form field should not be displayed.
I can set it to readonly by writing form.getItemProperty(“pid”).setReadOnly(true) but I cannot set it to non visible. The only possibility I have currently found is to define which fields should be displayed but not the other way round. Is this right?

Second question: Are there any annotion possibilities in the class Person to define the caption of the fields?
I am using vaadin 6.

Thank you for your help,
Florian

You could modify the field instead of the property :

form.getField("pid").setVisible(false);

Sorry, for the late reply, and many thanks to you for this advice, it has solved my problem.

Thanks,
Florian