How to change cursor to wait when switching views?

Our views are registered to Navigator and navigateTo is used to navigate from one view to another. Some views are pretty big and it takes time to show. Because there views are in memory, the loading indicator does now show up. In order to resolve the issue, we try to change cursor when we switch views.

The following ViewChangeListener is defined. The goal is to add styleName “wait_cursor” before view change (and hope the cursor is changed immediately), and remove it after view change.

private class MyViewChangeListener implements ViewChangeListener {

	@Override
	public boolean beforeViewChange(ViewChangeEvent event) {
		
		UI.getCurrent.addStyleName("wait_cursor");	//
		return true;
	}

    @Override
    public void afterViewChange(ViewChangeListener.ViewChangeEvent event) {
		UI.getCurrent.removeStyleName("wait_cursor");	//
    }

}

This does not work as expected. We confirmed that “wait_cursor” is defined correctly. Can anybody help to figure out what’s happening?

Thank you in advance.