cancel
Showing results for 
Search instead for 
Did you mean: 

bindElement without request

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (5)

Answers (5)

junwu
Active Contributor
0 Kudos

are u loading data from server?

if yes, how can u avoid the http request?

Former Member
0 Kudos

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!

ericci
Active Contributor
0 Kudos

Hi David, it's pretty much impossibile that your app is making server side request if you're using a JSONModel 😉

Are sure you're not using an oData Model?

Former Member
0 Kudos

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

former_member227918
Active Contributor
0 Kudos

can you share your code please?

-Akhilesh

Former Member
0 Kudos

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

former_member227918
Active Contributor
0 Kudos

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

former_member227918
Active Contributor
0 Kudos

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

junwu
Active Contributor
0 Kudos

use json model