Closed nkappler closed 6 months ago
Both usages are not supported. Aggregations don't support multiple (managed object) types. Either a single type or an interface can be used.
The altTypes
are meant to specify a primitive alternative, e.g. like string for the tooltip aggregation. The given type name must be resolvable via the DataType.getType
API. In UI5 1.x, this API was able to resolve a name as a global name to create an enum type from it. In UI5 2.x this is no longer supported as we abandon global names. That's the background of the - often misleading - error message.
We've meanwhile improved this error message in 1.121. It now reads:
[DEPRECATED] The type '${sTypeName}' was accessed via globals. Defining types via globals is deprecated. In case the referenced type is an enum: require the module 'sap/ui/base/DataType' and call the static 'DataType.registerEnum' API. In case the referenced type is non-primitive, please note that only primitive types (and those derived from them) are supported for ManagedObject properties. If the given type is an interface or a subclass of ManagedObject, you can define a "0..1" aggregation instead of a property
This still does not reflect the usage in altTypes
, but they're basically used to make single aggregations alternatively behave like properties.
OpenUI5 version: 1.120.2
Using UI5 Controls as altTypes produces an error, as if the Control would be an enum
This example:
is functionally identical to:
however, the first one produces the following error and the second doesn't
The type 'sap.m.MenuButton' was accessed via globals. Defining enums via globals is deprecated. Please require the module 'sap/ui/base/DataType' and call the static 'DataType.registerEnum' API. -