openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

OPENUI5 ODataV4 Complex SubStructures without Navigation Property

Open JFischerCN opened this issue 9 years ago • 21 comments

OpenUI5 version: 1.48.0

Browser/version (+device/version): Chrome 58

Any other tested browsers/devices(OK/FAIL): FAIL

URL (minimal example if possible):

User/password (if required and possible - do not post any confidential information here):

Steps to reproduce the problem:

  1. Given a OData V4 Source. The entity includes a property with a complex type.
  2. Binding to the entity and its properties works. Data is shown on screen.

What is the expected result? When changing data in the bound GUI elements, data shall be updated in properties within complex types.

What happens instead? Changes are reverted, the following error is logged: Failed to update path /Core(cff0d07a-baa3-4433-b02b-609471aabb69)/InfoSet_DE/ListDescription - Error: /Core(cff0d07a-baa3-4433-b02b-609471aabb69)/InfoSet_DE: Not a navigation property: InfoSet_DE

Any other information? (attach screenshot if possible)

<EntityType Name="Core" OpenType="true">
	<Key>
		<PropertyRef Name="Id"/>
	</Key>
	<Property Name="Id" Type="Edm.Guid" Nullable="false"/>
	<Property Name="Name" Type="Edm.String"/>
	<Property Name="Description" Type="Edm.String"/>
	<Property Name="ParentId" Type="Edm.Guid"/>
	<Property Name="TenantId" Type="Edm.Guid" Nullable="false"/>
	<Property Name="TypeDescriptor" Type="Edm.String"/>
	<Property Name="InfoSet_DE" Type="Comneos.MoMa.Server.Portal.ViewModels.InfoObjectLocalizedSet"/>
	</EntityType>
<ComplexType Name="InfoObjectLocalizedSet">
	<Property Name="LanguageISOCode" Type="Edm.String"/>
	<Property Name="ListTitle" Type="Edm.String"/>
	<Property Name="ListDescription" Type="Edm.String"/>
	<Property Name="Title" Type="Edm.String"/>
	<Property Name="Description" Type="Edm.String"/>
	<Property Name="Detail" Type="Edm.String"/>
	<Property Name="IsInUse" Type="Edm.Boolean" Nullable="false"/>
</ComplexType>

JFischerCN avatar May 16 '17 10:05 JFischerCN

Hello!

I would like to know more about the way you defined your UI, especially the data binding paths involved here. It sounds like a bug we fixed very recently.

Thanks for using OData V4!

Best regards, Thomas

ThomasChadzelek avatar May 17 '17 07:05 ThomasChadzelek

Hi,

Thank you very much for your support.

The data binding paths are basically following the structure, like

Core/InfoSet_DE/Name

and for reading from the model, they work (the GUI element got populated properly). It fails, though, upon updating with the indicated error message.

Is this information sufficient for you?

Thanks, regards

Jörg Fischer


Von: Dr. Thomas Chadzelek [email protected] Gesendet: Mittwoch, 17. Mai 2017 09:50:43 An: SAP/openui5 Cc: Jörg Fischer; Author Betreff: Re: [SAP/openui5] OPENUI5 ODataV4 Complex SubStructures without Navigation Property (#1485)

Hello!

I would like to know more about the way you defined your UI, especially the data binding paths involved here. It sounds like a bug we fixed very recently.

Thanks for using OData V4!

Best regards, Thomas

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/SAP/openui5/issues/1485#issuecomment-302013776, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AP4Gu3bPqn-OkgoQCnFp0ikXXdSCA8Ivks5r6qbTgaJpZM4NcT3a.

JFischerCN avatar May 17 '17 08:05 JFischerCN

Well, if you don't mind, I would like to see the relevant part of your XML view (or equivalent). I would like to make sure that it is indeed the issue we already fixed (then we can discuss which commit it is etc.) or whether it is s.th. new.

ThomasChadzelek avatar May 17 '17 08:05 ThomasChadzelek

Hi,

OK, so this is implemented generically: we have an XML View:

<mvc:View
   controllerName="..."
   xmlns="sap.m"
   xmlns:tnt="sap.tnt"
   xmlns:core="sap.ui.core"
   xmlns:mvc="sap.ui.core.mvc"
	xmlns:f="sap.ui.layout.form"
   height="100%">
  <f:SimpleForm
	minWidth="1024"
	maxContainerCols="2"
	editable="false"
	layout="ResponsiveGridLayout"
	labelSpanL="3"
	labelSpanM="3"
	emptySpanL="4"
	emptySpanM="4"
	columnsL="1"
	columnsM="1">
	<f:toolbar>
	  <Toolbar>
		<Title text="{i18n>InfoObjectLocalizedSet}" level="H4" titleStyle="H4"/>
		<ToolbarSpacer />
		<Button icon="sap-icon://delete" press="onDeleteLocalizedSet"/>
	  </Toolbar>
	</f:toolbar>
	<f:content>
	  <Label text="{i18n>Provision}"/>
	  <CheckBox selected="{IsInUse}"/>
	  <Label text="{i18n>Icon}"/>      
	  <Image src="{Icon/$value}"/>
	  <Label text="{i18n>Banner}"/>
	  <Image src="{Banner/$value}"/>
	  <Label text="{i18n>ListTitle}"/>
	  <TextArea value="{ListTitle}"/>      
	  <Label text="{i18n>ListDescription}"/>
	  <TextArea value="{ListDescription}"/>
	  <Label text="{i18n>Title}"/>
	  <TextArea value="{Title}"/>
	  <Label text="{i18n>Description}"/>
	  <TextArea value="{Description}"/>
	  <Label text="{i18n>Detail}"/>
	  <TextArea value="{Detail}"/>
	</f:content>
  </f:SimpleForm>
</mvc:View>

Which is loaded dynamically as a subview of the global view placed within a IconTabFilter. The IconTabFilter is bound to the substructure InfoSet_DE.

Data is showing up, when changing, the error is fired so the binding path seems correct.

Thanks, regards Jörg Fischer

JFischerCN avatar May 17 '17 08:05 JFischerCN

Hello Jörg!

I never had a doubt that your binding paths are correct, just wanted to better understand the scenario at hand. Now I got it sorted out. This is indeed a known issue (tracked internally as CPOUI5UISERVICESV3-122), sorry! I will discuss how to best proceed here.

Best regards, Thomas

ThomasChadzelek avatar May 17 '17 13:05 ThomasChadzelek

Hi,

Thank you very much for your efforts.

Please let me know if this issue will be resolved by a shortly upcoming new release or not.

Also, although a bit off topic, will OData V4 OpenTypes be supported by OPENUI5 ?

Thanks, regards

Jörg Fischer

Von: Dr. Thomas Chadzelek [mailto:[email protected]] Gesendet: Mittwoch, 17. Mai 2017 15:17 An: SAP/openui5 [email protected] Cc: Jörg Fischer [email protected]; Author [email protected] Betreff: Re: [SAP/openui5] OPENUI5 ODataV4 Complex SubStructures without Navigation Property (#1485)

Hello Jörg!

I never had a doubt that your binding paths are correct, just wanted to better understand the scenario at hand. Now I got it sorted out. This is indeed a known issue (tracked internally as CPOUI5UISERVICESV3-122), sorry! I will discuss how to best proceed here.

Best regards, Thomas

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/SAP/openui5/issues/1485#issuecomment-302086852, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AP4Gu9IIVddWavS3nPaksrXcu85rNQ2fks5r6vNVgaJpZM4NcT3a.

JFischerCN avatar May 17 '17 13:05 JFischerCN

Regarding "open types": we have no explicit support for it now and, as always, I cannot comment on timelines here. But, from a short glance at the spec, I would assume that you can already use such open types to a large extent. OpenUI5's V4 model does not validate against $metadata, i.e. you can use data binding against any property (but need to specify the type manually if the property is not described in $metadata). You can surely use any property name when you create a new instance. If you patch, there might be issues, but then we would like to hear about your experience. Give it a try!

ThomasChadzelek avatar May 17 '17 13:05 ThomasChadzelek

Good news for you: we are currently working on a fix for this issue (tracked internally as CPOUI5UISERVICESV3-136) and will downport it to 1.48 pretty soon.

ThomasChadzelek avatar May 17 '17 14:05 ThomasChadzelek

CPOUI5UISERVICESV3-136 has been fixed in 1.48 with commit 78df2c2fc7dcc3ae298bbcf6e576cd6f99ad90b6

ThomasChadzelek avatar May 22 '17 11:05 ThomasChadzelek

Hi, It seems the issue is not completely fixed: When doing an update, I can see OPENUI5 trying to submit the change to the substructure to a sub-URL of the main object. The URL path resembles the local path of the sub structure. However, this is not correct due to the following facts:

  1. The client model must not submit any change to the server until submitBatch(...) is called.
  2. As the server returns the information as a substructure to the client, I would also expect the client to hand over the changed substructure to the server and not calling a different URL.

Thanks, regards

Jörg Fischer

JFischerCN avatar May 29 '17 15:05 JFischerCN

Hello Jörg!

  1. This behavior should not change with the fix. Have you checked the developer guide at Batch Control? Sounds like an $$updateGroupId parameter is missing.
  2. This is per OData spec. The edit URL of a entity is different from its read URL in most cases, i.e. although you might GET from "Categories(ID=1)/Products(ID=1)", the PATCH request will target "Products(1)". See 4.2 Read URLs and Edit URLs and 4.3.1 Canonical URL. Please note that the instance annotation "@odata.editLink" is not yet supported by OpenUI5's V4 model.

Best regards, Thomas

ThomasChadzelek avatar May 29 '17 15:05 ThomasChadzelek

Hi,

Thank you very much for you support.

The substructure is modelled as a complexType, not as an entityType. My understanding is that in that case, there is no separate update mechanism but, instead, the JSON is transmitted as part of the update of the root element. Accordingly, the complexType has no key(s) defined.

Thanks, regards

Jörg Fischer

JFischerCN avatar May 30 '17 07:05 JFischerCN

Hello Jörg!

We have tried to reproduce your issue, but failed. Do you see a way to produce a self-contained example for Analysis? Or any other way to provide even more details than you already did? For example, showing the exact requests (URL, body) might help us understand the issue.

Best regards, Thomas

ThomasChadzelek avatar Jun 09 '17 07:06 ThomasChadzelek

Sorry, Jörg, that it took us so long, but we finally managed to reproduce your issue. We are tracking it internally as CPOUI5UISERVICESV3-732. Thanks for reporting!

As a workaround, you could try to bind the IconTabFilter to the Entity and use a relative binding for the SimpleForm that points to the complex type. Not sure if that is feasible for you, but the issue occurs because the binding which is sending the OData request is not responsible for an entity type, but for a complex type.

ThomasChadzelek avatar Jun 12 '17 13:06 ThomasChadzelek

Hello Jörg,

May I ask you some more questions about your setup? We are currently discussing that the fix I started is going into the wrong direction.

You said that the view is basically bound to the property "InfoSet_DE" of some instance of the Entity "Core", probably via setBindingContext(). The described problems imply that this binding has a cache of its own. We see two possible scenarios here:

1 You took some existing context to an entity instance (e.g. from a list). In this case the view's binding is relative and the entity resides in a parent cache. In this case we advise to avoid that a cache for the child binding is created, so that entity and property are in the same cache. 2 You called Model#createBindingContext. In this case the view's binding is absolute and the entity is not available at all for the PATCH request. This case is difficult. Our code expects to have the entity because our servers all expect an "If-Match" header with the entity's ETag.

Which scenario is it?

Regards, Uwe

UweReeder avatar Jul 13 '17 12:07 UweReeder

Hi, Thanks for your post. I used the bindElement operation on the GUI element to bind its context to the model part.

Thanks, regards

Jörg Fischer

JFischerCN avatar Jul 13 '17 12:07 JFischerCN

Hi Jörg,

Let me summarize what I understood so far. You bind the view via

oView.bindElement("/Core(cff0d07a-baa3-4433-b02b-609471aabb69)/InfoSet_DE")

This leads to a request

GET Core(cff0d07a-baa3-4433-b02b-609471aabb69)/InfoSet_DE

which fills the UI. Then you enter some text into the ListDescription which leads to a request

PATCH Core(cff0d07a-baa3-4433-b02b-609471aabb69)

{"InfoSet_DE":{"ListDescription":"your input"}}

Initially the PATCH request was not sent because the model ran into an error before. Later you had a discussion with Thomas on the format of the update request. What would you expect? "PATCH Core(cff0d07a-baa3-4433-b02b-609471aabb69)/InfoSet_DE" which is allowed by the OData spec?

We always patch the containing entity for various reasons:

  1. SAP OData servers do not allow PATCH on (complex) properties.
  2. SAP OData servers always require an "If-Match" header with the entity's E-Tag for modifying requests.
  3. When working with batch queues the OData model joins multiple updates for the same entity into one PATCH to minimize the number of requests.

Which server are you using? Does the PATCH request succeed in your scenario?

Regards, Uwe

UweReeder avatar Aug 02 '17 13:08 UweReeder

Hi

Thanks for your response. As the property is defined as ComplexType (in contrast to EntityType), my expectation ist that it is included in the GET Core(<GUID>) call. Then, as you pointed out, when updating that complex substructure, I would expect to have a PATCH Core(<GUID>) which includes the structure as outlined above. We do not use SAP OData as backend, though, we use an .NET based OData backend which supports PATCHing complex properties.

Thanks, regards

Jörg Fischer

JFischerCN avatar Aug 03 '17 07:08 JFischerCN

Hi Jörg,

please let us step back from expectations to observations for a moment. You bind the complex type and the request is GET Core(<GUID>)/InfoSet_DE? And the update is PATCH Core(<GUID>)? And what is its request message?

Regards, Uwe

UweReeder avatar Aug 03 '17 09:08 UweReeder

So the original issue here is resolved, but we will appreciate it if you share more details about the generated OData service. Possibly if you can share a link to the service or other test service that can produce the same issue.

Thanks

stephania87 avatar Oct 05 '18 13:10 stephania87