Composite component cuba 6.9

Hi All,

I need to create a component that consists of several other components. I see this requirement already provided in cuba platform ver 7.x , but I don’t see similar functionality in lower version, is there a way to achieve this by using cuba version 6.9 ?

Hi,

You can create complex components in any CUBA version, but in a less convenient way, e.g.:

public class WebSample extends WebAbstractComponent<CubaHorizontalActionsLayout> implements Sample {
    public WebSample() {
        this.component = new CubaHorizontalActionsLayout();
        this.component.setSpacing(true);

        // Create cuba components
        ComponentsFactory componentsFactory = AppBeans.get(ComponentsFactory.class);
        TextField textField = componentsFactory.createComponent(TextField.class);
        Button button = componentsFactory.createComponent(Button.class);

        // Add them to vaadin root component
        this.component.addComponents(textField.unwrap(Component.class), button.unwrap(Component.class));
    }
}

composite-component-demo.zip (82.4 KB)

Gleb

1 Like

Thanks @gorelov : I will try it, sorry very late response,