2024 Jun 17 7:48 PM - edited 2024 Jun 17 7:52 PM
I am facing a problem in sapui5 where my view is loading before the model maintained in the manifest.json is pulling data from the given json file and because of this the view is rendering blank. I have to refresh the page manually for view to wait for model to load before the view is rendered. I have used attachRequestCompleted function on the model to get model data but sometimes while navigating from one view to another I am facing this issue. I have also maintained preload: true for model in manifest. I can see the json file loading in the network tab. How can I solve this issue, does anyone have any idea?
Request clarification before answering.
Hi Amol,
Could you share a bit of code with us to see how you try to achieve this?
I assume you are loading the json file with the loadData function. This returns a promise (https://sapui5.hana.ondemand.com/#/api/sap.ui.model.json.JSONModel%23methods/loadData)
What you can do depends on your application. If you are using a router, you could implement an async await in your onObjectMatched function. This async awaits waits till the loadData is done and with the result (the json file) you could set it back to your jsonmodel with setData as junwu also suggests.
For the sake of simplicity I did not write error handling.
Kind regards,
Noël
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
jsonmodel.setData
or
jsonmodel.refresh(true)
either of them should make your view updated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 17 | |
| 8 | |
| 7 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 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.