getScreenData().loadAll() command

Hello Team,

What getScreenData().loadAll() command does?
I think that takes a detached Entity with an attribute changed (from client tier) and merge back to the managed Entity.
Am I correct?



Not exactly. It invokes load() method for all data loaders defined in the screen. We do not guarantee that all changes will be saved during reload.

Usually this method is used when you need to refresh all data displayed in the screen.

1 Like

It’s very strange because if I use this piece of code:

 transactionsDl.setParameter("organizationId", getEditedEntity().getId());

it works.
But if I use

transactionsDl.setParameter("organizationId", getEditedEntity().getId());

doesn’t work.

So what load() does? When I shoud use it?


Could you provide a bit more details please? What are you going to achieve and what are your actions? Is it possible to create a small example and attach?

I modified a query from Cuba 6 to Cuba 7

    public void onAfterShow(AfterShowEvent event) {
        transactionsDl.setParameter("organizationId", organizationDc.getItem().getId());

Why transactionDl.load is mandatory?


I’m a bit confused. You set a parameter to a data loader query, now you need to execute the loader, it is the expected behavior. You need to call load() to reload the data. You can refer to the documentation for details.

Without the full picture it is quite hard to say what you’re going to achieve.

So every time when a parameter is changed in the screen view, a loaderDl.load() command is mandatory, right?

You still have not defined what you are trying to do here. Usually, CUBA handles everything for you; you don’t usually interact directly with DLs in a normal entry screen. You are obviously trying to do something different/odd here, but you haven’t stated what it is that you’re trying to accomplish.

So … people are stabbing the dark trying to help you.

I think is very easy. My question is why/when the load() command should be used? There is a new (loader) approach in Cuba 7 (which was not present in Cuba 6) and is normal to ask for details.
I understand that load() is such kind of refresh. Why Cuba doesn’t refresh automatically and is necessary to call it programmatically? Or my understanding is wrong?
An example maybe would be great.

My question is why do you think you need to call load() at all? If you go into CUBA Studio, make an entry screen… you will see no calls to load() and the screen works just fine.

You only need to directly manipulate DLs when you’re trying to do something nonstandard.

Back to my example…I set a filter (query). Why this is nonstandard action and is mandatory to call DL?

If you want the data loader to reload the data set based on new criteria you need to tell it to do so… It can’t read your mind.

Can you define what new criteria means, pls?

You say you have some type of custom filter logic on this screen. If the parameters of said filter change, you have to reload the data.

However, CUBA has very powerful built in filters which are available automatically on every screen. Are you positive you need custom filter logic?

Yes, definitely positive. Look to another example (Cuba Petclinic).

    protected void completeVisit(Action.ActionPerformedEvent event) {
        Visit visit = visitsTable.getSingleSelected();
        boolean visitWasCompleted = visitStatusService.completeVisit(visit);

        if (visitWasCompleted) {       

without getScreenData().loadAll() the system throws an error: Object visit was modified in another transaction. Why such behaviour?


CUBA loads detached data from the database to a screen’s data container/ Detached means that there is no live connection to the database when the data is loaded. So, you have to make a separate request to the DB with new parameters if you want to apply a new filter.

Also, you can have a look at DataLoadCoordinator, maybe it will help you.

As for the example from the PetClinic: the Visit was changed by the service in the database, not in the screen. The screen does not have a live connection to the database, so you need to reload the entity after invoking the service.

Very good explanation, Andrey.
Thank you!.

1 Like