Idea: use Data Container as declarative DataManager #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Idea: Declarative DataManager Loading
In this branch the default treatment room in the UI is not loaded via
dataManager.load(DefaultTreatmentRoom.class).query("...").optional()
.Instead, the
dataCotainer
concept is utilized to define the loading of the optional instanceof the
DefaultTreatmentRoom
in a declarative XML based manner. This way, the java code is simplified in the controller. It only requires to define the parameter as well as pick up the value viadefaultTreatmentRoomDc.getItem()
.The Reason: higher level abstraction
The reason behind it is the same which led to the introduction of the various screen facets like the
MessageDialogFacet
. It pushes the complexity of "how to load a particular entity" into the declarative XML part. The Java code then can just rely on thedefaultTreatmentRoomDc
to correctly fetched the data. This simplifies the java code and provides a higher level abstraction in the UI controller to work with.Example: Default Treatment Room Lookup
The declarative definition of the instance container looks like this:
The controller code is simplified as described above:
Current Problems with the declarative approach
Currently it works well for the happy path: the
instanceContainer
actually returns a value. The problem occurs when there is no result. For a regularinstanceContainer
this is not very often the case, becausenormally an instance container is not used together with an associated data loader and a query.
But in this situation, the instance not being present by the query might be a valid business situation.
Currently, the
InstanceLoaderImpl
throws an exception in case the entity is not found:Therefore, it requires in the controller to catch this exception as well as explicitly trigger the dataLoader.load() in order to programmatically catch the exception.
Proposed Solution
In order to make the usage of
dataContainer
as a declarative way of using thedataManager
for this scenario work, it should be possible to mark an instance container as optional. This way when theinstanceContainer
is loaded and no result is foundgetItem()
would either return null or alternatively an instance ofOptional<DefaultTreatmentRoom>
.The resulting XML:
The corresponding controller code:
With this non-exception-when-null behavior it would also not require to explicitly trigger the dataLoader load anymore and the
@LoadDataBeforeShow