I'm trying to create form with Vaadin using "Binding form to data" with this class:
public class Job {
private String nom_projet;
private String svn;
private String planning1;
private String planning2;
private String goals;
}
with getters and setters.
When I try this everything works fine:
final Form form = new Form();
Job bean = new Job();
BeanItem<Job> item = new BeanItem<Job>(bean);
form.setItemDataSource(item);
I tried to add a custom field like its described in "Book of Vaadin" so I created this class:
public class MyFieldFactory implements FormFieldFactory {
private static final long serialVersionUID = 1L;
public Field createField(Item item, Object propertyId, Component uiContext) {
Select select = new Select("goals");
select.addItem("compiler:compile");
select.addItem("clean install");
select.addItem("clean");
select.addItem("package");
select.addItem("test");
select.setNewItemsAllowed(true);
return select;
}
}
But when I wanted to add this statement to MyApplication.java
:
form.setFieldFactory(new MyFieldFactory());
I got "setFieldFactory
" underlined and 3 choices:
- () Cast argument 1 to FieldFactory
- Change to setFirldFormFactory(...)
- Let 'MyFieldFactory' implements 'FieldFactory'
When I click on:
- Let 'MyFieldFactory' implements 'FieldFactory'
custom field does not appear in form.