cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SAPUI5 runtime context and browser refresh

Former Member
0 Likes
2,905

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

View Entire Topic
junwu
SAP Champion
SAP Champion
0 Likes

why go through the view?

did you try to access model in your controller? this.getOwnerComponent().getModel()

Former Member
0 Likes

Thanks for replay. Good Point. The reason is, that I want to access i18n model in various scenarios. Access to it is not working in some of my views and especially not if I am opening a dialog window using a view. This view instance does even not have a this.getOwnerComponent() method. Is there a way how to access this model independend from navigation status ? sap.ui.getCore().getModel(<modelName>) is not working this way. Using the proposed syntax "{i18n>textName}" leaves the text entities empty also. Any input is very welcome.