sap.ui.core.Core.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.ui.core.Core with name
sClassName
and enriches it with the information contained in
oClassInfo
.
oClassInfo
might contain the same kind of information as described in sap.ui.base.Object.extend.
Parameters:
{string} | sClassName | Name of the class being created |
{object} | oClassInfo? | Object literal with information about the class |
{function} | FNMetaImpl? | Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata |
Returns:
{function} | Created class / constructor function |
Returns a metadata object for class sap.ui.core.Core.
Returns:
applyChanges()
Enforces an immediate update of the visible UI (aka "rendering").
In general, applications should avoid calling this method and instead let the framework manage any necessary rendering.
applyTheme(sThemeName, sThemeBaseUrl?)
Applies the theme with the given name (by loading the respective style sheets, which does not disrupt the application).
By default, the theme files are expected to be located at path relative to the respective control library ([libraryLocation]/themes/[themeName]). Different locations can be configured by using the method setThemePath() or by using the second parameter "sThemeBaseUrl" of applyTheme(). Usage of this second parameter is a shorthand for setThemePath and internally calls setThemePath, so the theme location is then known.
sThemeBaseUrl is a single URL to specify the default location of all theme files. This URL is the base folder below which the control library folders are located. E.g. if the CSS files are not located relative to the root location of UI5, but instead they are at locations like http://my.server/myapp/resources/sap/ui/core/themes/my_theme/library.css then the URL that needs to be given is: http://my.server/myapp/resources All theme resources are then loaded from below this folder - except if for a certain library a different location has been registered.
If the theme resources are not all either below this base location or with their respective libraries, then setThemePath must be used to configure individual locations.
Parameters:
{string} | sThemeName | the name of the theme to be loaded |
{string} | sThemeBaseUrl? | the (optional) base location of the theme |
attachControlEvent(fnFunction, oListener?)
Registers a listener for control events.
Parameters:
{function} | fnFunction | callback to be called for each control event |
{object} | oListener? | optional context object to call the callback on. |
Attach event-handler fnFunction
to the 'formatError' event of sap.ui.core.Core
.
Please note that this event is a bubbling event and may already be canceled before reaching the core.
Parameters:
{function} | fnFunction | The function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'. |
{object} | oListener? | Object on which to call the given function. If empty, this Model is used. |
Returns:
attachInit(fnFunction)
Attaches a given function to the
initEvent
event of the core.
The given callback function will either be called once the Core has been initialized or, if it has been initialized already, it will be called immediately.
Parameters:
{function} | fnFunction | the callback function to be called on event firing. |
- Since:
- 1.13.2
attachIntervalTimer(fnFunction, oListener?)
Registers a listener to the central interval timer.
Parameters:
{function} | fnFunction | callback to be called periodically |
{object} | oListener? | optional context object to call the callback on. |
- Since:
- 1.16.0
attachLocalizationChanged(fnFunction, oListener)
Register a listener for the localizationChanged
event.
Parameters:
{function} | fnFunction | callback to be called |
{object} | oListener | context object to cal lthe function on. |
Attach event-handler fnFunction
to the 'parseError' event of sap.ui.core.Core
.
Please note that this event is a bubbling event and may already be canceled before reaching the core.
Parameters:
{object} | oData? | The object, that should be passed along with the event-object when firing the event |
{function} | fnFunction | The function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'. |
{object} | oListener? | Object on which to call the given function. If empty, this Model is used. |
Returns:
Attach event-handler fnFunction
to the 'validationError' event of sap.ui.core.Core
.
Please note that this event is a bubbling event and may already be canceled before reaching the core.
Parameters:
{object} | oData? | The object, that should be passed along with the event-object when firing the event |
{function} | fnFunction | The function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'. |
{object} | oListener? | Object on which to call the given function. If empty, this Model is used. |
Returns:
Attach event-handler fnFunction
to the 'validationSuccess' event of sap.ui.core.Core
.
Please note that this event is a bubbling event and may already be canceled before reaching the core.
Parameters:
{object} | oData? | The object, that should be passed along with the event-object when firing the event |
{function} | fnFunction | The function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'. |
{object} | oListener? | Object on which to call the given function. If empty, this Model is used. |
Returns:
Parameters:
{string|string[]} | vFieldGroupIds? | ID of the field group or an array of field group IDs to match |
Returns:
Returns the registered element for the given id, if any.
Parameters:
Returns:
createComponent(vComponent, sUrl?, sId?, mSettings?)
Creates a component with the provided id and settings.
When the optional parameter sUrl
is given, then all request for resources of the library will be redirected to the given Url. This is convenience for a call to
jQuery.sap.registerModulePath(sName, sUrl);
Parameters:
{string|object} | vComponent | name of the component to import or object containing all needed parameters |
{string} | vComponent.name? | name of the component to import |
{string} | vComponent.url? | URL to load the component from |
{string} | vComponent.id? | ID for the component instance |
{object} | vComponent.settings? | settings object for the component |
{string} | vComponent.componentData? | user specific data which is available during the whole lifecycle of the component |
{string} | sUrl? | the URL to load the component from |
{string} | sId? | the ID for the component instance |
{object} | mSettings? | the settings object for the component |
Returns a new instance of the RenderManager interface.
Returns:
detachControlEvent(fnFunction, oListener?)
Unregisters a listener for control events.
A listener will only be unregistered if the same function/context combination is given as in the attachControlEvent call.
Parameters:
{function} | fnFunction | function to unregister |
{object} | oListener? | context object given during registration |
Detach event-handler
fnFunction
from the 'formatError' event of
sap.ui.core.Core
.
The passed function and listener object must match the ones previously used for event registration.
Parameters:
{function} | fnFunction | The callback function to unregister |
{object} | oListener | Object on which the given function had to be called. |
Returns:
detachIntervalTimer(fnFunction, oListener?)
Unregisters a listener for the central interval timer.
A listener will only be unregistered if the same function/context combination is given as in the attachIntervalTimer call.
Parameters:
{function} | fnFunction | function to unregister |
{object} | oListener? | context object given during registration |
- Since:
- 1.16.0
detachLocalizationChanged(fnFunction, oListener)
Unregister a listener from the
localizationChanged
event.
The listener will only be unregistered if the same function/context combination is given as in the call to attachLocalizationListener
.
Parameters:
{function} | fnFunction | callback to be deregistered |
{object} | oListener | context object given in a previous call to attachLocalizationChanged. |
Detach event-handler
fnFunction
from the 'parseError' event of
sap.ui.core.Core
.
The passed function and listener object must match the ones previously used for event registration.
Parameters:
{function} | fnFunction | The callback function to unregister. |
{object} | oListener | Object on which the given function had to be called. |
Returns:
Detach event-handler
fnFunction
from the 'validationError' event of
sap.ui.core.Core
.
The passed function and listener object must match the ones previously used for event registration.
Parameters:
{function} | fnFunction | The callback function to unregister |
{object} | oListener | Object on which the given function had to be called. |
Returns:
Detach event-handler
fnFunction
from the 'validationSuccess' event of
sap.ui.core.Core
.
The passed function and listener object must match the ones previously used for event registration.
Parameters:
{function} | fnFunction | The function to call, when the event occurs. |
{object} | oListener | Object on which the given function had to be called. |
Returns:
Fire event formatError to attached listeners.
Expects following event parameters:
- 'element' of type
sap.ui.core.Element
- 'property' of type
string
- 'type' of type
string
- 'newValue' of type
object
- 'oldValue' of type
object
- 'exception' of type
object
Parameters:
{Map} | mArguments? | the arguments to pass along with the event. |
Returns:
Fire event parseError to attached listeners.
Expects following event parameters:
- 'element' of type
sap.ui.core.Element
- 'property' of type
string
- 'type' of type
string
- 'newValue' of type
object
- 'oldValue' of type
object
- 'exception' of type
object
Parameters:
{Map} | mArguments? | the arguments to pass along with the event. |
Returns:
Fire event validationError to attached listeners.
Expects following event parameters:
- 'element' of type
sap.ui.core.Element
- 'property' of type
string
- 'type' of type
string
- 'newValue' of type
object
- 'oldValue' of type
object
- 'exception' of type
object
Parameters:
{Map} | mArguments? | the arguments to pass along with the event. |
Returns:
Fire event validationSuccess to attached listeners.
Expects following event parameters:
- 'element' of type
sap.ui.core.Element
- 'property' of type
string
- 'type' of type
string
- 'newValue' of type
object
- 'oldValue' of type
object
Parameters:
{Map} | mArguments? | the arguments to pass along with the event. |
Returns:
Returns the registered component for the given id, if any.
Parameters:
Returns:
Returns the Configuration of the Core.
Returns:
getCurrentFocusedControlId(): string
Returns the Id of the control/element currently in focus.
Returns:
{string} | the Id of the control/element currently in focus. |
Returns the event bus.
- Since:
- 1.8.0
Returns:
Retrieves a resource bundle for the given library and locale.
If only one argument is given, it is assumed to be the libraryName. The locale then falls back to the current session locale. If no argument is given, the library also falls back to a default: "sap.ui.core".
Parameters:
{string} | sLibraryName?, Default: 'sap.ui.core' | name of the library to retrieve the bundle for |
{string} | sLocale? | locale to retrieve the resource bundle for |
Returns:
getLoadedLibraries(): map
Returns a map which contains the names of the loaded libraries as keys and some additional information about each library as values.
Experimental API:The details of the 'values' in the returned map are not yet specified! Their structure might change in future versions without notice. So applications can only rely on the set of keys as well as the pure existance of a value.
- Experimental:
- The details of the 'values' in the returned map are not yet specified! Their structure might change in future versions without notice. So applications can only rely on the set of keys as well as the pure existance of a value.
Returns:
{map} | map of library names / controls |
Returns the active MessageManager
instance.
- Since:
- 1.33.0
Returns:
Get the model with the given model name.
The name can be omitted to reference the default model or it must be a non-empty string.
Note: to be compatible with future versions of this API, applications must not use the value null
, the empty string ""
or the string literals "null"
or "undefined"
as model name.
Parameters:
{string|undefined} | sName? | name of the model to be retrieved |
Returns:
Returns the instance of the root component (if exists).
Returns:
getStaticAreaRef(): Element
Returns the static, hidden area DOM element belonging to this core instance.
It can be used e.g. for hiding elements like Popups, Shadow, Blocklayer etc.
If it is not yet available, a DIV is created and appended to the body.
Exceptions:
{Error} | an Error if the document is not yet ready |
Returns:
{Element} | the static, hidden area DOM element belonging to this core instance. |
Returns a UIArea if the given ID/Element belongs to one.
Parameters:
{string|Element} | o | a DOM Element or ID string of the UIArea |
Returns:
getUIDirty(): boolean
Returns true
if there are any pending rendering tasks or when such rendering tasks are currently being executed.
Returns:
{boolean} | true if there are pending (or executing) rendering tasks. |
hasModel(): boolean
Check if a Model is set to the core
Returns:
includeLibraryTheme(sLibName, sVariant?, sQuery?)
Includes a library theme into the current page (if a variant is specified it will include the variant library theme)
Parameters:
{string} | sLibName | the name of the UI library |
{string} | sVariant? | the variant to include (optional) |
{string} | sQuery? | to be used only by the Core |
initLibrary(vLibInfo)
Initializes a library for an already loaded library module.
This method is intended to be called only from a library.js (e.g. generated code). It includes the library specific stylesheet into the current page, and creates lazy import stubs for all controls and elements in the library.
As a result, consuming applications don't have to write import statements for the controls or for the enums.
Synchronously loads any libraries that the given library depends on.
Parameters:
{string|object} | vLibInfo | name of or info object for the library to import |
isInitialized(): boolean
Returns true if the Core has already been initialized. This means that instances of RenderManager etc. do already exist and the init event has already been fired (and will not be fired again).
Returns:
{boolean} | whether the Core has already been initialized |
isLocked(): boolean
Returns the locked state of the sap.ui.core.Core
Returns:
isMobile(): boolean
Check if the script is running on mobile
Returns:
isStaticAreaRef(oDomRef): boolean
Used to find out whether a certain DOM element is the static area
Parameters:
Returns:
{boolean} | whether the given DomRef is the StaticAreaRef |
isThemeApplied(): boolean
Returns true, if the styles of the current theme are already applied, false otherwise.
This function must not be used before the init event of the Core. If the styles are not yet applied an theme changed event will follow when the styles will be applied.
Returns:
{boolean} | whether the styles of the current theme are already applied |
loadLibrary(sLibrary, sUrl?)
Synchronously loads the given library and makes it available to the application.
Loads the *.library module, which contains all preload modules (enums, types, content of a shared.js if it exists). The library module will call initLibrary with additional metadata for the library.
As a result, consuming applications can instantiate any control or element from that library without having to write import statements for the controls or for the enums.
When the optional parameter sUrl
is given, then all request for resources of the library will be redirected to the given Url. This is convenience for a call to
jQuery.sap.registerModulePath(sLibrary, sUrl);
When the given library has been loaded already, no further action will be taken. Especially, a given Url will not be honored!
Note: this method does not participate in the supported preload of libraries.
Parameters:
{string} | sLibrary | name of the library to import |
{string} | sUrl? | URL to load the library from |
lock()
Locks the Core. No browser events are dispatched to the controls.
Lock should be called before and after the dom is modified for rendering, roundtrips... Exceptions might be the case for asynchronous UI behavior
registerPlugin(oPlugin)
Registers a Plugin to the
sap.ui.core.Core
, which lifecycle will be managed (start and stop).
Plugin object need to implement two methods:
startPlugin(oCore)
: will be invoked, when the Plugin should start (as parameter the reference to the Core will be providedstopPlugin()
: will be invoked, when the Plugin should stop
Parameters:
{object} | oPlugin | reference to a Plugin object |
Sets or unsets a model for the given model name.
The sName
must either be undefined
(or omitted) or a non-empty string. When the name is omitted, the default model is set/unset.
When oModel
is null
or undefined
, a previously set model with that name is removed from the Core.
Any change (new model, removed model) is propagated to all existing UIAreas and their descendants as long as a descendant doesn't have its own model set for the given name.
Note: to be compatible with future versions of this API, applications must not use the value null
, the empty string ""
or the string literals "null"
or "undefined"
as model name.
Parameters:
{sap.ui.model.Model} | oModel | the model to be set or null or undefined |
{string} | sName? | the name of the model or undefined |
Returns:
Defines the root directory from below which UI5 should load the theme with the given name. Optionally allows restricting the setting to parts of a theme covering specific control libraries.
Example: core.setThemeRoot("my_theme", "http://mythemeserver.com/allThemes"); core.applyTheme("my_theme");
will cause the following file to be loaded: http://mythemeserver.com/allThemes/sap/ui/core/themes/my_theme/library.css
(and the respective files for all used control libraries, like http://mythemeserver.com/allThemes/sap/ui/commons/themes/my_theme/library.css
if the sap.ui.commons library is used)
If parts of the theme are at different locations (e.g. because you provide a standard theme like "sap_goldreflection" for a custom control library and this self-made part of the standard theme is at a different location than the UI5 resources), you can also specify for which control libraries the setting should be used, by giving an array with the names of the respective control libraries as second parameter: core.setThemeRoot("sap_goldreflection", ["my.own.library"], "http://mythemeserver.com/allThemes");
This will cause the Gold Reflection theme to be loaded normally from the UI5 location, but the part for styling the "my.own.library" controls will be loaded from: http://mythemeserver.com/allThemes/my/own/library/themes/sap_goldreflection/library.css
If the custom theme should be loaded initially (via bootstrap attribute), the "themeRoots" property of the window["sap-ui-config"] object must be used instead of Core.setThemeRoot(...) in order to configure the theme location early enough.
Parameters:
{string} | sThemeName | the name of the theme for which to configure the location |
{string[]} | aLibraryNames? | the optional library names to which the configuration should be restricted |
{string} | sThemeBaseUrl | the base URL below which the CSS file(s) will be loaded from |
- Since:
- 1.10
Returns:
unlock()
Unlocks the Core.
Browser events are dispatched to the controls again after this method is called.
unregisterPlugin(oPlugin)
Unregisters a Plugin out of the sap.ui.core.Core
Parameters:
{object} | oPlugin | reference to a Plugin object |
attachInitEvent(fnFunction)
Attaches a given function to the
initEvent
event of the core.
This event will only be fired once; you can check if it has been fired already by calling isInitialized.
Parameters:
{function} | fnFunction | the function to be called on event firing. |
- Deprecated:
- since 1.13.2 Register to the more convenient init event instead
Creates a new sap.ui.core.UIArea.
Parameters:
{string|Element} | oDomRef | a DOM Element or ID string of the UIArea |
- Deprecated:
- Use
setRoot()
instead!
Returns:
Returns the instance of the application (if exists).
- Deprecated:
- Since 1.15.1. The Component class is enhanced to take care about the Application code.
Returns:
Returns the registered element for the given ID, if any.
Parameters:
- Deprecated:
- use
sap.ui.core.Core.byId
instead!
Returns:
Returns the registered element for the given ID, if any.
Parameters:
- Deprecated:
- use
sap.ui.core.Core.byId
instead!
Returns:
getRenderManager()
- Deprecated:
- Since version 0.15.0. Replaced by
createRenderManager()
Returns the registered template for the given id, if any.
Parameters:
- Deprecated:
- Since 1.29.1 Require 'sap/ui/core/tmpl/Template' and use Template.byId instead.
Returns:
setRoot(oDomRef, oControl)
Implicitly creates a new UIArea
(or reuses an exiting one) for the given DOM reference and adds the given control reference to the UIAreas content (existing content will be removed).
Parameters:
- Deprecated:
- Use function
oControl.placeAt(oDomRef, "only")
of sap.ui.core.Control
instead.