on 01-16-2023 10:37 AM
I have an issue with two-way binding when returning to a freestyle SAPUI5 app.
Say for example...
I navigate to App 1. The loads the OData fine, via two-way binding.
I then navigate away from App 1 to App 2. This also loads the OData for App 2 fine.
Now when I navigate back to App 1, The OData isn't loaded again, with the binding remaining from the first time into App 1.
I then navigate to App 2, same issue, the OData isn't reloaded, and the binding from the first entry into App 2 remains.
Ideally, I would like the binding cleared every time I enter an app, be it the 1st time in (initialization) or when navigating to it.
Is this possible to do with manifest properties? (much preferable) Or will a refresh need to be triggered in the controller?
adamharkus
I think, what you want to do is to bind the data each time you enter the app. You can use the <code>constructor</code> of the controller to bind the data.
onstructor: function (oView) {
this.oView = oView;
this._oDataModel = this.oView.getModel();
this.oView.bindElement({
path: "/path/to/data"
});
this.oView.setModel(this._oDataModel);
},
Whenever you enter the app, the constructor will be called and the <code>bindElement</code> will be executed and your data will be binded.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also, unBindElement does the job.
Thanks a lot yoganandamuthaiah
Hello Adam,
in order for the binding using the same path to make a request again and update the data, you need to invalidate the previous result in the model.
//check if model has some objects
if (!(Object.keys(this.getView().getModel().getData('/')).length === 0)) {
// make the path for current Entry
sPath = this.getView().getModel().createKey("/SomeSet", {
Key1: sKey1,
...
KeyN: sKeyN
});
this.getView().getModel().invalidateEntry(sPath);
} else {
sPath = ["/SomeSet(Key1='", sKey1, ... ,"',KeyN='", sKeyN, "')"].join("");
}
this.getView().bindElement({
path: sPath,
events : {
dataReceived: function(oEvent) {
...
}.bind(this)
}
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
check if it is related to this
https://sapui5.hana.ondemand.com/sdk/#/topic/46bf248182ed47cb85a05610abe361f7.html
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 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.