vaadin FormLayout设置自定义左:右侧组件

时间:2016-08-10 08:15:48

标签: vaadin7

在vaadin FormLayout中,我想显示多个组件(字段)。

enter image description here

enter image description here

1 个答案:

答案 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;
    }
}