Class sap.ui.core.FragmentModule: sap/ui/core/Fragment


Fragments support the definition of light-weight stand-alone UI control trees. This class acts as factory which returns the UI control tree defined inside the Fragments. When used within declarative Views, the Fragment content is imported and seamlessly integrated into the View.

Fragments are used similar as sap.ui.core.mvc.Views, but Fragments do not have a Controller on their own (they may know one, though), they are not a Control, they are not part of the UI tree and they have no representation in HTML. By default, in contrast to declarative Views, they do not do anything to guarantee ID uniqueness.

But like Views they can be defined in several Formats (XML, declarative HTML, JavaScript; support for other types can be plugged in), the declaration syntax is the same as in declarative Views and the name and location of the Fragment files is similar to Views. Controller methods can also be referenced in the declarations, but as Fragments do not have their own controllers, this requires the Fragments to be used within a View which does have a controller. That controller is used, then.

Do not call the Fragment constructor directly!

Use-cases for Fragments are e.g.: - Modularization of UIs without fragmenting the controller structure - Re-use of UI parts - 100%-declarative definition of Views

Constructor Summary
new sap.ui.core.Fragment()Accepts an object literal mSettings that defines initial property values, aggregated and associated objects as well as event handlers.
Method Summary
sap.ui.core.Fragment.byId(sFragmentId, sId)Returns an Element/Control by its ID in the context of the Fragment with the given ID
sap.ui.core.Fragment.createId(sFragmentId, sId)Returns the ID which a Control with the given ID in the context of the Fragment with the given ID would have
sap.ui.core.Fragment.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.ui.core.Fragment with name sClassName and enriches it with the information contained in oClassInfo.
sap.ui.core.Fragment.getMetadata()Returns a metadata object for class sap.ui.core.Fragment.
sap.ui.core.Fragment.registerType(sType, oFragmentImpl)Registers a new Fragment type
getType()Gets current value of property type.
setType(sType)Sets a new value for property type.
Methods borrowed from class sap.ui.base.Object
Constructor Detail
new sap.ui.core.Fragment()

Accepts an object literal mSettings that defines initial property values, aggregated and associated objects as well as event handlers. See sap.ui.base.ManagedObject for a general description of the syntax of the settings object.

The supported settings are:

  • Properties

In addition, all settings applicable to the base type sap.ui.base.ManagedObject can be used as well.

Method Detail
sap.ui.core.Fragment.byId(sFragmentId, sId)
Returns an Element/Control by its ID in the context of the Fragment with the given ID
Parameters:
{string}sFragmentId
{string}sId
sap.ui.core.Fragment.createId(sFragmentId, sId)
Returns the ID which a Control with the given ID in the context of the Fragment with the given ID would have
Parameters:
{string}sFragmentId
{string}sId
sap.ui.core.Fragment.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.ui.core.Fragment 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.ManagedObject.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
sap.ui.core.Fragment.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.ui.core.Fragment.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
sap.ui.core.Fragment.registerType(sType, oFragmentImpl)
Registers a new Fragment type
Parameters:
{string}sType the Fragment type. Types "XML", "HTML" and JS" are built-in and always available.
{object}oFragmentImpl an object having a property "init" of type "function" which is called on Fragment instantiation with the settings map as argument
getType(): string
Gets current value of property type.
Returns:
{string} Value of property type
setType(sType): sap.ui.core.Fragment
Sets a new value for property type.

When called with a value of null or undefined, the default value of the property will be restored.

Parameters:
{string}sType New value for property type
Returns:
{sap.ui.core.Fragment} Reference to this in order to allow method chaining