Skip to Content

How to keep local JSON data available through out the session ?

Hi,

I am copying data from odata model to local json model. This json model is declared in component.js file. Now when I refresh the page the data in this local json is lost. Is there a way I can keep a copy of the JSON model data through out the user session ?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Oct 19, 2019 at 11:48 AM

    You cannot directly persist the json model directly even when the page is refreshed. But you can save data using local storage to save data.

    There is blog about hybrid solution with json model and local storage, which might not work for your scenario but you can check it for useful information.

    https://blogs.sap.com/2018/03/19/easily-persist-state-with-jsonmodel-and-localstorage/

    Thanks,

    Mahesh

    Add a comment
    10|10000 characters needed characters exceeded

    • Yeah, that could be the case then. I was thinking, go back and forth between pages in an application is same as refreshing the application. But that basic understanding of mine is incorrect. Because, when I go back and forth b/w pages, I still can see data in the json model which is stored earlier. But the moment I refresh, it disappears.

      So I think I can live with it as long. Thanks Mahesh.

  • Posted on Oct 19, 2019 at 11:01 AM

    Define the model in manifest. Json to have a model available throughout session in all context

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.