You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We get feedback from some users that they don't understand what event they should listen to if they want to perform some screen initialization based on loaded data (collection containers, or edited entity graph in entity editor).
In topics above users tried to use InitEvent.
But for most users the most "safe" event to use when you need fully initialized screen - is "BeforeShow" (until you read the JavaDocs).
Because "BeforeShow" intuitively feels like "after all initialization is fully completed, right before showing the screen in the UI (attaching it to the main layout)".
Unfortunately BeforeShow event doesn't work this way. It is fired somewhere in the middle of the screen initialization process:
Event sent right before the screen is shown, i.e. it is not added to the application UI yet. ... Saved component settings are not yet applied to UI components. Data is not loaded yet for screens annotated with @LoadDataBeforeShow.
Contradictory description, isn't it? How it can be "right before" while settings weren't applied yet, and data wasn't loaded yet?
The proper event at the moment is the AfterShowEvent. However for some users it may feel intuitively wrong, because they tend to think that "UI is going to blink if I change something after the screen is shown". It is a false concern, but people have this feeling.
We cannot fix BeforeShowEvent in CUBA 7.2 without making breaking changes.
But we can make compatible change - by introducing new event.
Solution
Introduce new controller event - AfterDataLoad event. It should be listed in the list of "Controller events" in Studio which is displayed in the top of the event list, so that developers can easily find it by eyes.
This name suggests that you should choose this event if you want data to be loaded.
When this event should be triggered?
It should be triggered when all automatic data loading has been done.
If screen has @LoadDataBeforeShow - fire after this annotation has done its job
If screen has dataLoadCoordinator - fire after coordinator has done its job
If screen has neither of above items - what should we do??? To be discussed.
If don't fire at all - then we can built some logic into Studio (inspection with quick fix, don't suggest this event, automatically add annotation etc.)
If we decide to fire event - it can be misleading, because possibly presented data containers will be left uninitialized
throw exception maybe?
Possible alternatives
Per-data-loader (or data container?) event
Data context event
Controller event with other name/meaning, not directly related to data loading. E.g. "FullyReady" event, when all operations are 100% completed including applying UI settings etc.
But in all cases it should be something very simple, targeted to newbies using Studio capabilities. Pro developers shouldn't have problems with reading JavaDocs and relalizing to use AfterShow or listen to DataLoader itemChanged / collectionChanged events.
The text was updated successfully, but these errors were encountered:
Environment
Description of the bug or enhancement
We get feedback from some users that they don't understand what event they should listen to if they want to perform some screen initialization based on loaded data (collection containers, or edited entity graph in entity editor).
e.g.
https://www.cuba-platform.com/discuss/t/for-looping-through-child-entity-to-set-edit-ability-of-screen-components/8237/2
or
https://www.cuba-platform.com/discuss/t/geteditedentity-in-edit-screen/12785
In topics above users tried to use InitEvent.
But for most users the most "safe" event to use when you need fully initialized screen - is "BeforeShow" (until you read the JavaDocs).
Because "BeforeShow" intuitively feels like "after all initialization is fully completed, right before showing the screen in the UI (attaching it to the main layout)".
Unfortunately BeforeShow event doesn't work this way. It is fired somewhere in the middle of the screen initialization process:
Contradictory description, isn't it? How it can be "right before" while settings weren't applied yet, and data wasn't loaded yet?
The proper event at the moment is the AfterShowEvent. However for some users it may feel intuitively wrong, because they tend to think that "UI is going to blink if I change something after the screen is shown". It is a false concern, but people have this feeling.
We cannot fix BeforeShowEvent in CUBA 7.2 without making breaking changes.
But we can make compatible change - by introducing new event.
Solution
Introduce new controller event - AfterDataLoad event. It should be listed in the list of "Controller events" in Studio which is displayed in the top of the event list, so that developers can easily find it by eyes.
This name suggests that you should choose this event if you want data to be loaded.
When this event should be triggered?
It should be triggered when all automatic data loading has been done.
Possible alternatives
But in all cases it should be something very simple, targeted to newbies using Studio capabilities. Pro developers shouldn't have problems with reading JavaDocs and relalizing to use AfterShow or listen to DataLoader itemChanged / collectionChanged events.
The text was updated successfully, but these errors were encountered: