Skip to Content
author's profile photo Former Member
Former Member

Best practice to store global data?

Hi,

i´m new with SAPUI5 and started to create an application using sapui5 mvc with javascript-views.

After login i need to save some global properties but i don´t know the best practice.

I want to access this properties out of many controllers.

Is there any way to place a JSON-Object with global access?

Thank you

Best regards

Sascha Köhler

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Dec 11, 2014 at 08:23 AM

    Hi Sascha,

    one option would be to store your JSON Object via a JSON Model in the sap.ui.core.

    • Create your JSON Object.
    • Create a JSON Model and add the JSON object to it (var oJSONModel = new sap.ui.model.json.JSONModel(<your JSON Object>);).
    • Add JSON Model to core (sap.ui.getCore().setModel(oJSONModel, <your identifier>);).
    • With sap.ui.getCore().getModel(<your identifier>); you can access the JSONModel.

    But as always: Avoid global things if possible 😉

    Regards,

    Florian

    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.