jmix icon indicating copy to clipboard operation
jmix copied to clipboard

Tab injection does not work when TabSheet is placed in component container

Open Flaurite opened this issue 2 years ago • 0 comments

Environment

Jmix version: 2.1.3

Bug Description

See Russian support forum: topic.

When TabSheet is placed in VerticalLayout/HorizontalLayout/FormLayout and probably other layouts, controller dependency injector cannot find Tab instance.

Steps To Reproduce

  1. Add to XML:
<layout>
    <vbox>
        <tabSheet id="tabSheet2"
                  width="100%">
            <tab id="tab3" label="tab3">
                <span text="content"/>
            </tab>
            <tab id="tab4"
                 label="tab4">
                <span text="content"/>
            </tab>
        </tabSheet>
        <hbox>
            <tabSheet id="tabSheet1"
                      width="100%">
                <tab id="tab1" label="tab1">
                    <span text="content"/>
                </tab>
                <tab id="tab2" label="tab2">
                    <span text="content"/>
                </tab>
            </tabSheet>
        </hbox>
    </vbox>
</layout>
  1. Add to the controller:
@ViewComponent("tabSheet1.tab1")
private Tab tab1;
@ViewComponent("tabSheet2.tab3")
private Tab tab3;

@Subscribe
public void onBeforeShow(final BeforeShowEvent event) {
    Objects.requireNonNull(tab1);
    Objects.requireNonNull(tab3);
}
  1. Set debug breakpoint to onBeforeShow

Current Behavior

Both instances are null.

Expected Behavior

Tabs are not null.

Flaurite avatar Feb 09 '24 09:02 Flaurite