on 10-10-2016 2:26 PM
Hey,
I want to make my App offline capable. When I switch my views the bindElement() method is called and is always making a request against the backend. Is there any possiblity to set the data manually without making a request?
Thanks for your help and best regards,
David
are u loading data from server?
if yes, how can u avoid the http request?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I use a JSON Model, but I'm very new to SAPUI5, so a little bit more input would be nice 😉 If you have an example how to set the data manually with a JSON Model that would be nice. Thank you very much!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Akhilesh,
thanks for your reply. I've tested your suggestion, but it stills triggers a HTTP request... any other ideas how I can solve this issue?
Thanks for your help and best regards,
David
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I found the problem why a HTTP request is still triggered...
In my model I have a navigation attribute. When I switch the view, the data is initialized, but the data for the navigation attribute is always requested from backend (but it is already available in my JSON Model).
Is there any possibility to access the objects from my JSON Model and no HTTP request is triggered?
Thank you very much and best regards,
David
1) if you are trying to load data from server once and use json model
I think you didn't changed binding code in attachRoutePatternMatched function, that still pointing to oDataModel navigation property,
instead of binding view with the navigation property (oView.bindElement(sObjectPath)), do something like below:
//set json model(may be named model) to view :
oView.setModel(oJsonModel, "jModel");
oView.bindElement("/jModel>/results");
using above code data will be pulled from json model only.
2) if you don't want any sever request even for initial load and working with json model(with hard coded data)
then, replace oDataModel with json model(with hard coded data) in component.js file only, and replace navigation property with json model.
Hope will be helpful.
-Akhilesh
Hello David,
you can use a json model for it, read data from backend once or you can test using hard coded data, once data is ready set that data to json model and set this model to view.
lets say you have json data is like below, then you can do bindElement as below:
oData={"results":[]};
.bindElement("/results");
Hope this will help you.
Regards,
Akhilesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
use json model
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.