Data Lost when switching from pages

Here is my scenario :

I’ve two pages, PageA and PageB. Page A gets the data from a REST service and shows it as a grid.

The problem is when I’m in Page B and click on the back button to go back to Page A, the grid is blank. I loose all data. Please let me know how this can be fixed

Page A looks like this after calling the REST API

unknown.png

After switching from Page B to Page A ( I just click the back button in the browser ) , the page looks like this ( this is the default page with no data )

unknown.png

There are multiple solutions depending on your use case and requirements.

  • use UIScope on the view so that the same view is rerendered with the old fetched data
  • use Before or After Navigation listener to fetch the data every time the view is shown
  • some other fancy mechanism related to caching

Thanks for the response. Here is the result after making the changes as per your suggestion

UIScope did not work. It is loosing the data again

I cannot use this Before or After Navigation listener because the grid is displayed based on the combo box value

Well I don’t know your view’s structure but using UIScope works normally if you don’t have a flaw somewhere :wink:

may be because I have the values stored in memory

page a : http://localhost:8080/acebuddy, page b: http://localhost:8080/about

now when switching from page b to page a , I loose all data

Page A calls a REST API and saves the values in a List for the grid

page A is UIScoped

unknown.png

I tried with @PreserverOnRefresh also but no luck

If you wanna see that e.g. UI scope works you can create a test view, annotate it with it and just add a grid in the constructor with 2 rows of dummy data and e.g. a console log that the constructor is only called once even if you are navigating back and forth

This works. I tried with a grid which gets data from DB and that also works. But mine is bit different. It is neither using DB nor any static values. It is having the values a in a LIST and that is decided based on the comoboBox value

yeah sounds like you should debug your view :wink: probably related to value change listener in the combo box that clears the grid