答案 0 :(得分:1)
您可以构建扩展com.vaadin.ui.CustomComponent的自定义Component(下面的示例)。 如果你想使用字段绑定,事情变得更复杂,你应该扩展com.vaadin.ui.AbstractField并覆盖更多的方法。
SuperCustom dateSelection = new SuperCustom("Caption on left side in FormLayout");
formLayout.addComponent(dateSelection);
class SuperCustom extends CustomComponent {
ComboBox ordinal = new ComboBox();
ComboBox day = new ComboBox();
ComboBox month = new ComboBox();
public SuperCustom(String caption) {
setCompositionRoot(new HorizontalLayout(ordinal, day, new Label("of"), month));
configureComponents();
setCaption(caption);
}
private void configureComponents() {
//fill comboboxes
}
public Date getValue() {
//build date based on fields
return date;
}
}