Hello,
We have a UI5 application utilizing a OData Model V2 (SAP Gateway) two-way binding, quite straight forward I'd say.
I think I understand the view binding and retrieving the bound context within event handlers. But I can't wrap my head around updating a reference/object. I have a single record bound to a view displaying the data in a form. Some properties are reference via 'expand' (UI5 binding) using the NavigationProperty (Gateway/OData).
Pseudo-Binding like:
<Input binding="{model>/user('ernie')}" value="{model>name}" />
<Text binding="{path: 'model>/user('ernie'), expand: 'NavUserDetails'}" '" text="{model>NavUserDetails/email}" />
The above is not actually there but it should illustrate that the bound context has a 1:1 navigation to another entity (UserDetails) which is displayed. Depending on the entered name the details are supposed to adjust (reload).
However the reload (correct display of Text element) only happens whenever I commit the updated Input (requires a db store). After the PUT request the UI5 model reloads the data from the backend.
Now my question is can I manually replace the object property (navigation) without commiting the name. I already have all the users loaded by the model - it is de-facto available in the model including the UserDetails entities. I want to avoid a commit, I simply want the user to be able to reset some fields and explicitly hit a save button whenever done.
What I tried is to set the Property in the event handler like
oContext = oControlEvent.getSource().getBindingContext("model"); //get User entity model>/User('bert') var oUserEntity = oContext.getModel().getObject("model>/User('" +" oContext.getProperty("name") +"')" ) ; //does not work - even if the return is true oContext.getModel.setProperty("NavUserDetails", oUserEntity, oContext); //does not work - even if the return is true oContext.getModel().bindContext(oContext.getPath() +"/NavUserDetails", oUserEntity);
I also tried to set the property "NavUserDetails" with the context object of the user entity with no success. I already get the impression that this is not intended by the framework but maybe I just need a good hint.
thanks in advance