I know that you can get a single Component with:
sap.ui.component("ComponentID");
But is there also a way to list all components that live in the current window context?
Thx Chris
I know that you can get a single Component with:
sap.ui.component("ComponentID");
But is there also a way to list all components that live in the current window context?
Thx Chris
sap.ui.component(string)
delegates to sap.ui.getCore().getComponent()
. With that you can query a specific component by id.
There at the sap.ui.core.Core
is a registry of components. But its marked as private and even has a TODO to get rid of it. So i would advice to not access that directly.
You can get the available components through Component.registry.
> sap.ui.core.Component.registry.all()
{component-name: fnClass}
// You can use Object.keys to get the names
> Object.keys(sap.ui.core.Component.registry.all())
['component-name']
And then you can use this name to fetch the actual component, either through Core.getComponent, Component.get or Componeny.registry.get (and i wouldn't even be surprised if where a dozen other options in the documentation).
> sap.ui.getCore().getComponent("component-name") // pre 1.95
> sap.ui.core.Component.get("component-name") // post 1.95
fnClass {_oMetadataProxy: UIComponentMetadata, _oManifest: constructor, _mManifestModels: {…}, _mServices: {…}, getMetadata: ƒ, …}