Search code examples
javanavigationvaadincdi

How to refresh CDIView to reflect changes made in another CDIView?


I am using cdi-helpers addon and my UI extends ViewMenuUI. I have CDIViews like

OGSContractView

@UIScoped
@CDIView("Contract")
@ViewMenuItem(order = ViewMenuItem.DEFAULT, icon = FontAwesome.BANK)
public class OGSContractView extends CssLayout implements View{ 
    // There's some UI Fields and some Functions to refresh the UI Fields
    public void RefreshList(){...}
}

and

SchoolView

@UIScoped
@CDIView("School")
@ViewMenuItem(order = ViewMenuItem.DEFAULT, icon = FontAwesome.BANK)
public class SchoolView extends CssLayout implements View{
    //Some UI and functions inside
    //here, after some changes, I want to call a Refresh_Function 
    //from my OGSContractView class
    someData.saveInDatabase();
    ogsContractView.refreshList(); // here is my problem
}

In SchoolView, I am changing some data in the database and after that I want to call OGSContractView.refreshList() to update some ui fields there.

How can I do this?


Solution

  • For updated question. You do not need to call refresh() from the another view.

    You can override method public void enter(ViewChangeEvent event) on OGSContractView, like

    @Override
    public void enter(ViewChangeEvent event) {
       refresh():
    }
    

    Above method is called by internal navigator each time you enter to that view.