Legacy API Method
|
Deprecation Information
|
applyChanges
|
Applications and controls should not call this method explicitly as the framework handles necessary rendering. The applyChanges() method enforces a synchronous rendering and must not be used in future-proof, productive code.
|
applyTheme
|
Use Theming.setTheme() instead. However, this will no longer support providing a new theme root via an "@" symbol. In URL parameters, usage of the "@" symbol is still available.
See Setting Themes for more details.
|
attachControlEvent
|
Applications and controls should avoid listening to all control events, but rather listen to specific events provided by the control classes.
|
attachFormatError
|
Use ManagedObject#attachFormatError() instead.
See related information for attachParseError() .
|
attachInit
|
Use Core.ready() instead. While the behavior is nearly identical, the ready() function also allows for Promise chaining and awaiting the Core ready state.
sap.ui.require(["sap/ui/core/Core"], async function(Core) {
Core.ready(() => {
// this callback is executed directly in case the Core is
// already in ready state, otherwise it is executed at a later point in time
});
// You can also use the ready() function as a Promise, e.g.
Core.ready().then(...)
// or await it
await Core.ready();
});
As an alternative to programmatically chaining to the Core's ready state, you can also use a dedicated on-init module, which will be required and executed automatically once the Core is ready:
<script id='sap-ui-bootstrap'
data-sap-ui-async='true'
data-sap-ui-resource-roots='{"my": "./"}'
data-sap-ui-on-init='module:my/initModule'
...>
</script>
|
attachInitEvent
|
Use Core.ready() instead.
|
attachIntervalTimer
|
Use IntervalTrigger.addListener() instead.
|
attachLocalizationChanged
|
Use Localization#attachChange() instead.
Instead of relying on Localization.attachChange() and manually attaching an event handler for localizationChanged , we recommend to use the generic control hook onLocalizationChanged on your sap.ui.core.Element subclasses instead.
The generic control hook has been renamed from onlocalizationChanged to onLocalizationChanged (mind the capital letter "L").
The generic control hook captures all changes on settings exposed via the sap/base/i18n/Localization facade, as well as the changes to settings exposed via thesap/base/i18n/Formatting facade.
The old LocalizationChanged event was fired on each relevant localization and format settings change.
The change event of the new Localization facade only captures the settings that are changeable via said facade. However, if you are interested in the changes of the format settings, additionally use the change event of the sap/base/i18n/Formatting facade.
The Event object has a different API than on the Core facade. There is no more getParameters() , but simple properties like the Web API events (see the sample below).
See Localization$ChangeEvent or Formatting$ChangeEvent , respectively.
Instead of the former APIs onlocalizationChanged() or attachLocalizationChanged() , see the following sample:
/// generic control hook
MyControl.prototype.onLocalizationChanged = function() {};
// Localization API
sap.ui.require([
"sap/base/i18n/Localization",
"sap/base/i18n/Formatting"
], (Localization, Formatting) => {
Localization.attachChange((oEvent) => {
// Note: The event callback has no <this> context anymore,
// thus we use an arrow function here
// Note: the Event object has a different API than on the Core facade:
// no more getParameters(), but simple properties like the Web API events.
// Therefore, you can access the newly set "language" like so:
const sLanguage = oEvent.language;
});
// additional setting changes can be captured via the Formatting facade
Formatting.attachChange((oEvent) => {
// s.a.
});
});
|
attachParseError
|
Use ManagedObject#attachParseError() instead.
Overall, the events parseError , validationError , formatError and validationSuccess have been deprecated. Use the corresponding APIs on subclasses of sap/ui/base/ManagedObject .
Component-based applications should rather prefer framework controlled validation handling (manifest flag "sap.ui5"/"handleValidation" ).
Tests and samples that are not Component-based should attach validation event listeners to a suitable control in the control tree instead.
sap.ui.require([
"sap/ui/core/Component"
], async (Component) => {
const oComponent = await Component.create({
name: "my.component"
});
const fnParseErrorHandler = function () {
// Error handling
};
oComponent.attachParseError(fnParseErrorHandler);
oComponent.detachParseError(fnParseErrorHandler);
});
|
attachThemeChanged
|
For applications and test code, see Theming.attachApplied() as an alternative. For controls, use the generic control hook onThemeChanged on your sap.ui.core.Element subclasses instead.
The Event object has a different API than on the Core facade. There is no more getParameters() , but simple properties like the Web API events.
The handler of the applied event will be executed immediately once, in case all *.css files are loaded and there are no further requests pending for the theme.
After that, it will only be executed in case of new *.css files, which may happen for a complete theme change or loading of additional libraries. Keep in mind that the onThemeChanged hook is not executed initially in case the theme is already applied.
|
attachValidationError
|
Use ManagedObject#attachValidationError() instead.
See related information for attachParseError() .
|
attachValidationSuccess
|
Use ManagedObject#attachValidationSuccess() instead.
See related information for attachParseError() .
|
byFieldGroupId
|
Use Control#getControlsByFieldGroup() instead.
|
byId
|
Use Element.getElementById() instead.
sap.ui.require(["sap/ui/core/Element"], async function(Element) {
const oMyElement = Element.getElementById("myId");
});
|
createComponent
|
Use Component.create() instead.
|
createRenderManager
|
A separate RenderManager should not be used.
|
createUIArea
|
Use Control#placeAt() instead.
|
detachControlEvent
|
See attachControlEvent() above.
|
detachFormatError
|
Use ManagedObject#detachFormatError() instead.
See related information for attachParseError() .
|
detachIntervalTimer
|
Use IntervalTrigger.removeListener() instead.
|
detachLocalizationChanged
|
Use Localization#detachChange() instead.
|
detachParseError
|
Use ManagedObject#detachParseError() instead.
See related information for attachParseError() .
|
detachThemeChanged
|
See Theming.detachApplied() instead.
|
detachValidationError
|
Use ManagedObject#detachValidationError() instead.
See related information for attachParseError() .
|
detachValidationSuccess
|
Use ManagedObject#detachValidationSuccess() instead.
See related information for attachParseError() .
|
fireFormatError
|
Use ManagedObject#fireFormatError() instead.
|
fireParseError
|
Use ManagedObject#fireParseError() instead.
|
fireValidationError
|
Use ManagedObject#fireValidationError() instead.
|
fireValidationSuccess
|
Use ManagedObject#fireValidationSuccess() instead.
|
getApplication
|
The Component class is enhanced to take care about the application code.
|
getComponent
|
Use Component.getComponentById() instead.
|
getConfiguration
|
See Deprecated Configuration API for detailed information to handle legacy sap.u.core.Configuration via replacements for the respective APIs.
|
getControl
|
Use Element.getElementById() instead. See example at byId() .
|
getCurrentFocusedControlId
|
Use Element.getActiveElement() to get the currently focused element. You can then retrieve the ID of that element with Element#getId() . Keep in mind that Element.getActiveElement() may return undefined .
|
getElementById
|
Use Element.getElementById() instead. See example at byId() .
|
getEventBus
|
Use EventBus.getInstance() for global usage instead. However, the global EventBus should only be used if there is no other option to communicate between different instances. Whenever possible, you should prefer native control events, View or Component (lifecycle) events.
sap.ui.require([
"sap/ui/core/EventBus"
], (EventBus) => {
const oEventBus = EventBus.getInstance();
});
If needed, a new private EventBus instance may be created via the constructor, which decouples it from any other parties subscribed to the global EventBus :
const oMyOwnEventBus = new EventBus();
oMyEventBus.subscribe("my-channel-id", "my-event-id")
oMyEventBus.publish("my-channel-id", "my-event-id", { /* data */ })
|
getLibraryResourceBundle
|
Use Lib.getResourceBundleFor() instead.
Note that the new API may unintentionally still load the ResourceBundle for the given library synchronously, which is to be avoided. Therefore, make sure to always either load the library beforehand or maintain it as a Component or Library dependency, so that you can prevent such synchronous loading of *.properties files.
// Retrieve ResourceBundle when library was already loaded beforehand.
// This is the case for controls inside their own library
sap.ui.require(["sap/ui/core/Lib"], async (Library) => {
// ensures the library is loaded
await Library.load({ name: "sap.m" });
// ResourceBundle can be retrieved
const oRB = Library.getResourceBundleFor("sap.m")
});
|
getLoadedLibraries
|
Applications should avoid performing operations on all loaded libraries. This concept is reserved for the framework itself and dedicated support use cases.
|
getMessageManager
|
Use Messaging instead.
// example, replacing legacy sap.ui.getCore().getMessageManager().addMessage()
sap.ui.require([
"sap/ui/core/Messaging",
"sap/ui/core/message/Message
], (Messaging, Message) => {
Messaging.addMessage(new Message({
text: "My message text"
}));
});
|
getModel
|
Deprecated without direct replacement. See the information on setModel() below for a potential use via ManagedObject#getModel() instead.
|
getRenderManager
|
A separate RenderManager should not be used.
|
getRootComponent
|
Use sap/ui/core/ComponentSupport instead. See also Declarative API for Initial Components.
|
getStaticAreaRef
|
Use StaticArea.getDomRef() instead. It provides more possibilities, e.g. you can also retrieve the static UIArea directly, if needed.
sap.ui.require([
"sap/ui/core/StaticArea"
], (StaticArea) => {
// Direct replacement
const oStaticArea = StaticArea.getDomRef();
// Retrieving the static UIArea directly
oStaticUIArea = StaticArea.getUIArea();
// Check whether the given DOM element is part of the static area
const bContainedInArea = StaticArea.contains(myControl.getDomRef())
});
|
getTemplate
|
Use an XMLView or a Typed View instead.
|
getUIArea
|
For access to the static UIArea, use the StaticArea instead.
|
getUIDirty
|
Applications and controls should avoid querying the rendering state and should rely on the standard rendering lifecycle of the framework.
|
hasModel
|
Use ManagedObject#hasModel() instead.
|
includeLibraryTheme
|
Applications and controls should avoid interfering with the loading of library.css files. All library theme files are maintained and orchestrated by the framework.
Use Lib.load() instead to ensure the loading of the corresponding theme files.
|
initLibrary
|
Use Lib.init() instead.
// the object is no longer passed into sap.ui.getCore().initLibrary()
sap.ui.require(["sap/ui/core/Lib"], (Library) => {
Library.init({
name: "my.library",
version: "${version}",
dependencies: ["sap.ui.core", "..."],
types: [
...
],
interfaces: [],
controls: [
...
],
elements: [
...
],
extensions: {
...
}
});
});
|
isInitialized
|
Deprecated without replacement. It should no longer be necessary as it was mainly used to avoid accessing APIs before the Core was ready, but these other Core APIs have been deprecated as well.
// Nevertheless, if you still have a need for isInitialized, maybe use the following
sap.ui.require(["sap/ui/core/Core"], async function(Core) {
let isInitialized = false;
Core.ready(() => {
isInitialized = true;
});
if (isInitialized) {
...
}
});
|
isLocked
|
Locking the event handling of the sap.ui.core.Core is considered an anti-pattern and should be avoided.
|
isMobile
|
Use Device.browser.mobile instead.
|
isStaticAreaRef
|
Use StaticArea.contains() instead.
|
isThemeApplied
|
For applications and test code, see Theming.attachApplied() as an alternative. For controls, use the generic control hook onThemeChanged on your sap.ui.core.Element subclasses instead.
See attachThemeChanged for related information.
|
loadLibrary
|
Use Lib.load() instead.
// instead of legacy loading via sap.ui.getCore().loadLibrary("my.library")
sap.ui.require(["sap/ui/core/Lib"], (Library) => {
Library.load({
name: "my.library"
});
});
|
lock
|
Locking the event handling of the sap.ui.core.Core is considered an anti-pattern and should be avoided.
|
notifyContentDensityChanged
|
Use Theming.notifyContentDensityChanged() instead.
|
registerPlugin
|
Albeit plugins are not meant for public usage, the common need to access the set of all controls/elements or all components can now be achieved using the sap.ui.core.Element.registry or sap.ui.core.Component.registry APIs, respectively.
|
sap.ui.core.Core.extend
|
sap.ui.core.Core is a singleton and should not be sub-classed.
|
sap.ui.core.Core.getMetadata
|
sap.ui.core.Core is a singleton and the metadata of the internal class should not be accessed.
|
setModel
|
Deprecated without direct replacement. The future-proof Core facade no longer acts as a model provider.
Component-based applications should prefer manifest models.
Tests and samples which are not Component-based may attach models to a suitable control in the control tree instead, e.g. via ManagedObject#setModel() .
|
setRoot
|
Use oControl.placeAt(oDomRef, "only") instead.
|
setThemeRoot
|
Theme roots should not be changed at runtime. Instead, provide the corresponding sap-ui-theme-roots configuration option via either the bootstrap, meta tag, or an URL parameter. See Setting Themes for more details.
|
unlock
|
Locking the event handling of the sap.ui.core.Core is considered an anti-pattern and should be avoided.
|
unregisterPlugin
|
See registerPlugin above.
|