cuba-platform / cuba

CUBA Platform is a high level framework for enterprise applications development
https://www.cuba-platform.com
Apache License 2.0
1.34k stars 219 forks source link

Error when overriding datasource filters in inherited screen #3274

Open vao-igel opened 2 years ago

vao-igel commented 2 years ago

Platform version: 6.10.17

Steps to reproduce:

  1. Create browser screen with collectionDatasource, add filter to this datasource with structure:
<filter>
 <and>
  <c>some filter expression</c>
 </and>
</filter>

Filter must contain exactly one \<c> element. If it has two or more the bug does not occur.

  1. Create screen inherited from the first one, override the filter for the same datasource by adding several elements:
<filter>
 <and>
  <c>expression1</c>
  <c>expression2</c>
  <c>expression3</c>
 </and>
</filter>

When running and debugging the loading phase of the datasource of the overridden screen it is seen that only the last filter expression is present in filter. I found that this error originates in the class XmlInheritanceProcessor in method "private void process(Element resultElem, Element extElem)" at lines 153-158: if the element from base screen has only one child (not affected by any locator) then all the children of the same element from inherited screen will be merged into it by method "private void process(Element resultElem, Element extElem)". Using attribute "ext:index" does not help. The only way to avoid this behavior is create two filter expressions in base screen. Maybe it can be fixed by adding the element "list.get(0)" to "justAdded" collection after line 155.

gorbunkov commented 2 years ago

It works like it is described in the documentation:

Otherwise, the platform determines how many elements with the provided path and name are contained in the parent descriptor. If there is only one element, it is overridden.

I think you can try adding different id attributes to the <c> tag in original and extended screens. If these elements have ids, they won't be overriden.

vao-igel commented 2 years ago

When I put 2 or 3 \<c> elements in extended screen they do not just override the initial single \<c> element, they all collapses into one in the result screen description. I don't think that this is a correct behavior.

gorbunkov commented 2 years ago

they all collapses into one in the result screen description

Could you provide an example? I don't get what do you mean by all element collapses into one.