question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enhancement Request: Being able to add XMLComposite to explicitly typed aggregations

See original GitHub issue

Motivation

Several controls await specific type in their aggregation instead of just sap.ui.core.Control. E.g.:

  • Page’s custom header/ footer awaiting controls of type sap.m.IBar
  • ListBase awaiting controls of type sap.m.ListItemBase
  • (and more…)

Problem

In the latter case, sap.m.CustomListItem is an often used control to have a customized layout consisting of any desired controls. To encapsulate the customized list item, there are mainly two options:

  1. Using as a fragment

    <items>
      <core:Fragment fragmentName="my.CustomListItem" type="XML" />
    </items>
    
    <!-- Fragment definition of my.CustomListItem -->
    <CustomListItem xmlns="sap.m">
      <SomeContainer property="{model>/property}">
        <!-- ... -->
      </SomeContainer>
    </CustomListItem>
    

    Drawbacks

    • Binding infos are already defined in the fragment definition. One cannot use the same fragment in a different context with different bindings declaratively.
    • Fragment is designed to be view context aware (unless it’s a control in the static area) encouraging tight coupling with a specific view or application.
    • Behaviors aren’t meant to be encapsulated either.

    So it’s not really encapsulating.

  2. Creating a custom composite control by extending ListItemBase or CustomListItem

    Drawbacks

    Compared to the first approach where we could assemble controls declaratively, it’s more complex and error-prone.

    ui5con-2018-news-from-control-development-5-1024

    Source: UI5con 2018: News from Control Development by @akudev

This leads to the (currently experimental) XMLComposite approach.

What is the expected result?

The extended XMLComposite control, which has CustomListItem as the only root control (see fragment definition above), can be added to the <items> aggregation of the ListBase control.

<List xmlns:custom="my.custom">
  <custom:MyCustomListItem ... />
</List>

What happens instead?

I’m not allowed to add <custom:MyCustomListItem> since it’s not of type sap.m.ListItemBase, even though the top control is CustomListItem which is extended from ListItemBase.

After all, XMLComposite borrows the idea of Fragment. And fragments don’t have their own representation in DOM. Following this concept, it would be nice if <custom:MyCustomListItem> is treated as <CustomListItem>.

Any other information?

Same issue: https://answers.sap.com/questions/754215/composite-control-xmlcomposite-for-a-listitem.html

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
mzimnncommented, Mar 5, 2021

I think it’s really unfortunate that the XMLComposite has been deprecated. Is there an official alternative we can be used instead?

1reaction
codeworriorcommented, Feb 19, 2019

I think the problem is with (the missing) multiple inheritance. Typed aggregations only allow instances of the specified type or subclasses thereof. If the type is an interface, implementations of that interface are expected.

But XMLComposite is a base class by itself. It is not a feature or mixing that can be used to implement a subclass of another control class. Therefore, it is not possible to implement an XMLComposite that fits into a typed aggregation with a non-interface-type (interface types shouldn’t be a problem).

Fragments solve this problem by “disappearing at runtime”. Only the type of their root content has to match the enclosing aggregation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Composite Control (XMLComposite) for a ListItem
Hi everyone, i would like to create a composite control like it's ... to be able to assign XMLComposite to specifically typed aggregations....
Read more >
EclipseLink/DesignDocs/328404 new - Eclipse Wiki
This feature adds support for persistence units being composed. ... set of entity types and expose them through a composite persistence unit ...
Read more >
121 Configuring a Mapping - Oracle Help Center
Select the Read-Only option to set the mapping to be read-only and not ... A type conversion converter is used to explicitly map...
Read more >
Index of Deprecated APIs - SAPUI5 SDK
This feature has been deprecated with the classic homepage. ... Type of object in the landscape ... Enumeration of possible HorizontalDivider types.
Read more >
Genericity, extensibility and type-safety in the ... - CiteSeerX
Instances of GP include the generics (parametrization by types) mechanism as found in recent versions Java and C# and. Datatype-Generic Programming (DGP) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found