Refreshing screen fragments from host screen

I am displaying statistics of collection as shown in image in browse screens. These indicators are screen frames showing data taken using service beans.

cuba_frame

@Subscribe
    private void onAfterInit(AfterInitEvent event) {
    label.setValue(dashboardService.PendingCMCount(userSession.getUser()));
    }

I want to refresh these frames by table refresh button click or preferably whenever there are changes in entities.

How can I refresh these frames?

regards

Umesh

Hi,

I would recommend refresh frames in the CollectionChangeEvent handler, so every time the data container is refreshed, items are added or removed you will be notified.

Regards,
Gleb

Sorry, but i am not able to conceive the code to refresh the frame.

@Inject
    private Pendingcm fragment1;

    @Subscribe(id = "complianceMonitoringsDc", target = Target.DATA_CONTAINER)
    private void onComplianceMonitoringsDcCollectionChange(CollectionContainer.CollectionChangeEvent<ComplianceMonitoring> event) {
        //what should be code here?
    }

How can I refresh frgment1 or its label componenet and fire bean? May please suggest code.

regards

Umesh

Thanks, Got it. Just mistake on my part (the function was defined private, so i am not able to access it.)

As far as I understand, currently you refresh frames only when the screen is opened. I assumed that you will move the code that refreshes frames from onAfterInit to onComplianceMonitoringsDcCollectionChange. It seems that I misunderstood and onAfterInit is a code from a frame, not from the hosting screen. In this case, We’d greatly appreciate if you manage to create a sample project demonstrating the issue.

Thanks @gorelov

The issue is resolved. I shifted on refresh code to new public function and called that from host screen.

Umesh