on 2016 Jan 14 2:16 PM
Hi,
I observed the following behaviour: I created a navigation path and a number of models to be used in my App. The models are created in Component.js means centrally. I can easily access them from my MainView by this.getModel(). In the target View I am processing the model content. To access it there, I run
| var oModelAnchor = sap.ui.getCore().byId(cModelAnchorViewID); | ||
| var oModelL = oModelAnchor.getModel(cModelName); |
cModelAnchorViewID is the view ID of the main View and cModelName is containing the name of the model. Modeltype is JSON the viewtypes are XML and javascript. Code works fine as long as I use the implemented sapui5 navigation functionality.
As soon as I am refreshing the page, when I am on the target view by using the browser refresh button, the runtime context changes. My anchor view is not longer accessible and the first line of code is returning undefined. To work around the problem I declared the model locally to this view.
Any ideas why this happens? Obviously this behaviour is having significiant impact on how to implement value handling along navigation paths.
thanks for feedback.
WPdat
Request clarification before answering.
Hi Wolfgang,
I´m not sure if this helps but I used
sap.ui.getCore().setModel()
and
sap.ui.getCore().getModel()
for my models which I have to access from different views. My development environment is currently broken so I cannot test if this solves the issue with page refresh. But maybe you give it a try.
Best regards,
Sebastian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Wolfgang,
Today my dev environment is working again and I tested it.
In component.js I set a global model:
// define a global model for global properties / attributes (global variables/ settings)
var oGlobalProperties = {
sServiceUrl: sServiceUrl,
mockserver: {
isStarted: bIsMocked
}
};
var oGlobalJSONModel = new sap.ui.model.json.JSONModel(oGlobalProperties);
sap.ui.getCore().setModel(oGlobalJSONModel, "GlobalProperties");
Then I can access the model from anywhere in my app by calling
sap.ui.getCore().getModel("GlobalProperties")So, not sure what´s different in your app and what you exactly tried but this works for me and it works perfectly after refreshing the page by pressing F5.
Best regards,
Sebastian
Im facing the same issue.
Your suggestion is working, but i want to change Json dynamically when its navigating from 1st view to 2nd view.
I have posted new thread here https://scn.sap.com/message/16511272#16511272
Can you help me to resolve this issue ?
Thanks & Regards
Yokesvaran Kumarasamy
| User | Count |
|---|---|
| 8 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.