[CUBA 7] Target does not support BeforeShowEvent

Here are the involved sources.7z (6.4 KB).

The hierarchy is FacilityBrowse -> FacilityBrowseFragment. In FacilityBrowseFragment, actionPerformed (line 121) code is ran, I get the following Exception thrown in the UI: exception.txt (5.1 KB). The mentioned code opens FacilityView, that contains FacilityEditFragment.

I can’t see what I’m doing wrong, because I don’t subscribe to any BeforeShowEvent of the ScreenFragment, I subscribe to the BeforeShowEvent of the TARGET_CONTROLLER.

Any help will be appreciated.

Hello @bujoralexandru1996

You’re getting the exception because screen fragments support only the following event types:

  • InitEvent
  • AfterInitEvent
  • AttachEvent
  • DetachEvent

Regards,
Daniil

You could subscribe on PARENT_CONTROLLER though:

@Subscribe(target = Target.PARENT_CONTROLLER)
private void onParentShow(Screen.BeforeShowEvent event) {
}
1 Like

Yes, I know that, but if inside a Screen (0) we add a fragment (1) which adds another Fragment (2) which adds another Fragment (3), will (3)'s method of onParentShow be called when (0) appears? Because I investigated further and I’m not calling BeforeShowEvent from any of my fragments, I just use BeforeShowEvent with target = Target.PARENT_CONTROLLER.

Why do you need so deep nesting?

This works only if your fragment controller is the direct child of the Screen. Otherwise you’d better provide your own API for that or subscribe to BeforeShowEvent of the screen programmatically.

1 Like