[CUBA 7] Getting ScreenFragments by their id

I have a UI Controller class:

public class FormulaFragment extends ScreenFragment { ... }

I have a fragment that is declaratively declared inside the xml inside a lazy-loaded tab, thus it cannot be injected.

<fragment id="formulaFragment" .../>

Is there a more elegant way of retrieving the fragment’s controller from inside the parent controller than this?

FormulaFragment formulaFragment = (FormulaFragment) ((WebFragment) getFragment().getComponentNN(“formulaFragment”)).getFrameOwner();

PS: I try to get the FormulaFragment controller after the lazy-loaded tab has been initialized.

Hello @bujoralexandru1996

Could you clarify whether your fragment is inside of another fragment tabsheet?

Please provide a layout to be more clear.

Regards,
Daniil

Hello Daniil,

So let’s say I have a fragment (fragment1) in which I declare a tabsheet. In that tabsheet, I declare a lazy-loaded tab, in which I declare some random fragment (fragment 2).

The random fragment cannot be injected into fragment 1’s controller, because it is inside a lazy loaded tab.

Is there a more elegant way of obtaining fragment 2’s controller?

Okay, thank you.

Unfortunately there’s no any other way to get inner fragment.

Ok, thanks!

Probably will wrap those casts in a non visual UI component in a more readable manner.