How to Refresh the main Screen to update table added to it

Good day.

I am new to Cuba Studio. I have created an application with a main screen that contains a table that displays data. This table in the main screen should auto update or refresh when data in main table changes. My question is: How do i refresh the main screen when i close all the open tabs? Currently i have to logout and login again to see the changes but this is not reliable.

Thank you
Indileni

Hi,

You can use API of AppWorkArea component:

public class ExtAppMainWindow extends AppMainWindow {
    @Override
    public void init(Map<String, Object> params) {
        super.init(params);

        workArea.addStateChangeListener(newState -> {
            if (newState == AppWorkArea.State.INITIAL_LAYOUT) {
                // update data here
            }
        });
    }
}

Thank you, the state check is working good but having problems with updating the main screen.

This is my code

public void onClosetabsbtnClick() {
    	
    	WebWindowManager wm = (WebWindowManager) getWindowManager();
    	wm.closeAllTabbedWindows();
    	
    	workArea.addStateChangeListener(newState -> {
    		if(newState.equals(AppWorkArea.State.INITIAL_LAYOUT)){
    			projectdatasource.refresh();
    		}
    	});
    }

I added projectdatasource.refresh() to refresh the table but it is giving me a NullPointerException. I dont understand why? Can you please brief me on how to update data on the main screen.

Thank you

I managed to figure it out. I changed the name of the datasource projectsDs to projectdatasource and it couldn’t be found that’s why it was returning a NullPointerException.

Thank you for your help