on 07-07-2020 5:23 PM
Hi
Another mystery yet to be resolved and the posts I found does not really give proper solution.
We have OData v4 services implemented with CAP and we now want to implement freestyle UI5 applications that will use the OData v4 services.
The UI5 SDK documentation assumes there is a list binding and the "Creating an Entity" section only refers to the sap.ui.model.odata.v4.ODataListBinding#create method.
Our application does not start with a list, e.g. the user can click on a button upon which a dialog appears to receive input data and upon clicking Save button it saves the new object data.
In this case, how can we create a transient entity without a "list" that can then be saved with submitBatch?
Hello Serdar!
Thanks for using OData V4! Turns out that sap.ui.model.odata.v4.ODataListBinding#create is indeed the right method, even if you do not show a table UI. As discussed in Accessing Data in Controller Code, "A list binding is obtained either with sap.ui.model.odata.v4.ODataModel#bindList
, or by getting an existing list binding bound to a control." Once you have a list binding, there is no need to read data at all before creating a new entity! You can even create this new entity when you open the dialog, get back a v4.Context immediately, and use it as a binding context for the dialog!
Best regards,
Thomas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi thomas.chadzelek ,
I think what you've described is best shown in the following sample of the UI5 documentation. However, in our case we want to create the new entry, when the user clicks 'OK'. We want to use a close button to just close the dialog. I currently don't see the way how to do it right, as we don't want to introduce a new entry by just clicking on the plus sign in the table toolbar.
Thanks,
-Steffen
Hello steffen ,
please note that you can easily create a transient context which only lives on the client-side. You can control when the actual POST is send to the server. This transient context is useful for the dialog, I would assume, because it can receive the needed user input and provide automatic type determination and even value help, all based on metadata. You can cancel this transient context and never send the POST if the user cancels the dialog (see also Creating an Entity). Or you submit the corresponding batch group (see Batch Control) in case OK is clicked. In other words: "create the new entry, when the user clicks 'OK'" (from a server perspective) is not the same as creating the new entry on the client much earlier.
Best regards,
Thomas
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
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.