Skip to Content
0

Model data gets lost on browser navigation

May 08, 2017 at 02:23 PM

63

avatar image

I am having a weird problem with one specific site in my SAPUI5 application where model data gets lost if i navigate back and then forward again. The view consists of two lists which are populated from the same list inside the model like this:

First List:

<List items="{
      path: 'startlist>/startlistElements',
      sorter: {
        path: 'competitors/0/rankOfficial'
      },
      filters: [
        {
          path: 'competitors/0/isMarked',
          operator: 'EQ',
          value1: true
        }
      ]
    }">

Second List (same view):

  <List showNoData="false" items="{
      path: 'startlist>/startlistElements',
      sorter: {
        path: 'time'
      },
      filters: [
        {
          path: 'competitors/0/isMarked',
          operator: 'EQ',
          value1: false
        }
      ]
    }">

Here is an example what happens if i navigate back and forth inside the browser:

1. Initial load (everything is fine):

2. Navigate Back and Forward with the Browser (flag cannot be loaded, because the name of the image inside the model seems to be empty):

3. Navigate Back and Forward again with the Browser (now it seems to be spreading - even the names inside the model where previously only the flag was missing is missing, and the second row is also affected):

If i do this over and over more and more data gets missing until the second list only has question-marks as images (The first list in the view is NOT affected by this!). If i then repeat the process everything gets back to normal for the next load and then starts all over again.

What could cause such an issue? I am using JSON-Models to load my data from a REST-Service. I can see that all requests (also after navigating back and forward again) are non-cached requests and the data which seems to be missing is also returned from the server normally.

Thanks for any help

initial-load.png (12.0 kB)
again.png (10.6 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Tobias Kammerer May 08, 2017 at 06:20 PM
0

I have solved my own problem but i am not sure why this is the problem.

I was setting the model for the view inside the attachRequest callback:

oJSONModel.attachRequestCompleted(function(oEvent) {
    this.getView().setModel(oJSONModel);
}.bind(this)

and somehow this was the problem. After calling the setter right away the problem went away..

Share
10 |10000 characters needed characters left characters exceeded
Tobias Kammerer May 08, 2017 at 04:15 PM
0

Just noticed that this also occurs when i navigate back using a router:

var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
oRouter.navTo('startlist');
Share
10 |10000 characters needed characters left characters exceeded