In the Form with bean data model for user input, currently I know it supports replaceWithSelect to have Select component for user choosing some value as input, does the form also support Radio Button within bean data model, because if I just have few choices e.g. less than 4 ones, I want to use Radio Button instead of Select so that user can do choice without pulling-down Select list (user can see all choices without any mouse operation) , how can I do this, it’s better if Vaadin supports replaceWithRadioButton …
Sure you can, you just have to add a FormFieldFactory to generate the correct field. Here is an example where I replace the “age” property with radio buttons:
form.setFormFieldFactory(new FormFieldFactory() {
public Field createField(Item item, Object propertyId, Component uiContext) {
if (propertyId.equals("age")) {
return new OptionGroup("Age", Arrays.asList(5,10,20));
}
return DefaultFieldFactory.get().createField(item, propertyId,
uiContext);
}
});
Just remember to add the FormFieldFactory before you set the data source.