cancel
Showing results for 
Search instead for 
Did you mean: 

Model data gets lost on browser navigation

puelo
Explorer
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

puelo
Explorer
0 Kudos

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..

Answers (1)

Answers (1)

puelo
Explorer
0 Kudos

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

var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
oRouter.navTo('startlist');