Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sap.ui.core.mvc.ControllerExtension does not allow multiple extend calls #3891

Closed
dfenerski opened this issue Nov 8, 2023 · 2 comments
Closed

Comments

@dfenerski
Copy link
Contributor

dfenerski commented Nov 8, 2023

OpenUI5 version: latest

Browser/version (+device/version): CR latest

URL (minimal example if possible):

ce = sap.ui.core.mvc.ControllerExtension.extend('my.ns', {test: function(){console.error('bla')}})
ce.extend // undefined

compared to

b = sap.m.Button.extend('my.ns', {test: function(){console.error('foo')}})
b.extend // allows subclasses 

What is the expected result?
ControllerExtension does not allow inheritance & reuse of ControllerExtensions is therefore limited e.g I can't have the same base extension in a lib and 2 specialized extensions, inheriting the base one's functionality in apps.

@tsanislavgatev
Copy link
Contributor

I've created an internal incident 2370143666. The status of the issue will be updated here in GitHub.

@Thodd
Copy link
Contributor

Thodd commented Nov 16, 2023

Hi @dfenerski,

I discussed this topic with the responsible colleagues and the behavior you're seeing is actually intentional.

Extending a ControllerExtension by class inheritance conflicts with the override mechanism provided by the extensions.
So basically, multiple inheritance layers are not supported as of now.
On a technical level, the second subclassing is prevented by making the extension class final: true.
The reasoning is that a ControllerExtension must only be "extended" via the overrides, where final flags and the privacy setting (public: true or public: false) can be correctly validated.

See also here for the override functionality:
https://ui5.sap.com/#/api/sap.ui.core.mvc.ControllerExtension%23methods/sap.ui.core.mvc.ControllerExtension.override

To be fair the documentation is rather lacking and there already are two internal backlog item for the team to enhance the documentation:

  • CPOUI5FRAMEWORK-117
  • CPOUI5FRAMEWORK-150

Hope that helps you out a bit.

Best regards,

Thorsten

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants