Use app extensions with caution and only if you cannot produce the required behavior by other means, such as manifest settings or annotations. To correctly integrate your app extension coding with SAP Fiori elements, use only the extensionAPI of SAP Fiori elements. For more information, see Using the extensionAPI.
After you've created an app extension, its display (for example, control placing, CSS) and system behavior (for example, model and binding usage, busy handling) of the app extension lies within the application's responsibility. SAP Fiori elements provides support only for the official extensionAPI functions. Don't access or manipulate SAP Fiori elements' internal coding.
For global actions, you do not have to select a line in the list report table. This type of action refers to the whole list report, for example, Display Log. Global actions are placed in the list report filter bar next to the Share button.
.controller.js file for your
extension.
In the code sample below, we assume the following:
App name: my_app
MyListReportExt.controller.js
(extending the ListReport controller),
MyObjectPageExt.controller.js
(extending the ObjectPage controller)my_app/webapp/ext/controllerListReport controller, your controller extension
should look like this:
sap.ui.define("my_app.ext.controller.ListReportExtension", [], function() {
return {
onCustomAction1 : function(oEvent) { … },
onCustomAction2 : function(oEvent) { … },
…
}
})
When implementing the handler functions for your custom actions, you must use the Using the extensionAPI.
In your app's manifest.json file, under sap.ui5 → extends →
extensions, you can specify extensions for the
ListReport and the ObjectPage
controllers.
Specify the following information and extend the manifest files as described below:
|
|
Entity set that is displayed on the list report or on the
object page (for example,
If you use multiple views with different
|
|
|
Action names |
|
|
ID to be used for the action button The values of the action name and the ID should be identical. |
|
|
nullText to be displayed on the button (typically a binding to an i18n entry, for
example, null<button
text>nullnull |
|
|
Handler function that is called when the user selects the action button |
|
|
Indicates whether this is a global action. The default value is
If a determining property is set along with the global property, the action is rendered as a global action since this takes precedence. |
|
Relevant only for table toolbar actions in the list
report and object page:
|
Property that indicates whether the action requires a selection of items. The default
value is |
|
Relevant only for list report actions and object page
header actions: |
Property that indicates whether the action should be displayed in the footer of the
page.
The default value is |
|
Relevant only for object page actions: |
ID that either comes from the annotation in which you have provided an ID for the facet or that's made up of the annotation term plus the navigation property. For example: <entity type association>::com.sap.vocabularies.UI.v1.LineItem |
Table toolbar action for the list report
...
"extends": {
"extensions": {
"sap.ui.controllerExtensions": {
"sap.suite.ui.generic.template.ListReport.view.ListReport": {
"controllerName": "my_app.ext.controller.ListReportExtension",
"sap.ui.generic.app": {
"<entity set>": {
"EntitySet": "<entity set>",
"Actions": {
"<Action 1>": {
"id" : "<id>",
"text" : "<button text>",
"press" : "<handler function>",
"requiresSelection": <true|false>
},
"<Action 2>": {
...
},
...
}
...
Action for the object page header
...
"extends": {
"extensions": {
"sap.ui.controllerExtensions": {
...
"sap.suite.ui.generic.template.ObjectPage.view.Details": {
"controllerName": "my_app.ext.controller.DetailsExtension",
"sap.ui.generic.app": {
"<entity set>": {
"EntitySet": "<entity set>",
"Header" : {
"Actions": {
"<Action 1>": {
"id" : "<id>",
"text" : "<button text>",
"press" : "<handler function>"
},
"<Action 2>": { ... }
}
},
...
Table toolbar action for the object page
...
"extends": {
"extensions": {
"sap.ui.controllerExtensions": {
...
"sap.suite.ui.generic.template.ObjectPage.view.Details": {
"controllerName": "my_app.ext.controller.DetailsExtension",
"sap.ui.generic.app": {
"<entity set>": {
"EntitySet": "<entity set>",
"Sections": {
"<SmartTable Facet ID>": {
"id" : "<SmartTable Facet ID>",
"Actions": {
"<SmartTable Action 1>": {
"id" : "<id>",
"text" : "<button text>",
"press" : "<handler function>",
"requiresSelection": <true|false>
},
"<SmartTable Action 2>": { ... }
}
...
Form action for the object page
...
"extends": {
"extensions": {
"sap.ui.controllerExtensions": {
...
"sap.suite.ui.generic.template.ObjectPage.view.Details": {
"controllerName": "my_app.ext.controller.DetailsExtension",
"sap.ui.generic.app": {
"<entity set>": {
"EntitySet": "<entity set>",
"Sections": {
"<Form Facet ID>": {
"id": "<Form Facet ID>",
"Actions": {
"<Action 1>": {
"id" : "<id>",
"text" : "<button text>",
"press" : "<handler function>"
},
"<Action 2>": { ... }
}
...
Footer bar action in the list report:
"sap.ui5": {
"extends": {
"extensions": {
"sap.ui.controllerExtensions": {
"sap.suite.ui.generic.template.ListReport.view.ListReport": {
"controllerName": "my_app.ext.controller.ListReportExtension",
"sap.ui.generic.app": {
"<entity set>": {
"EntitySet": "<entity set>",
"Actions": {
"<Action 1>": {
"id": "<id>",
"text": "<button text>",
"press": "<handler function>",
"determining": true
}
}
}
}
}
}
}
}
}
Footer bar action in the object page:
"sap.ui5": {
"extends": {
"extensions": {
"sap.ui.controllerExtensions": {
"sap.suite.ui.generic.template.ObjectPage.view.Detail": {
"controllerName": "my_app.ext.controller.DetailsExtension",
"sap.ui.generic.app": {
"<entity set>": {
"EntitySet": "<entity set>",
"Header": {
"Actions": {
"<Action 1>": {
"id": "<id>",
"text": "<button text>",
"press": "<handler function>",
"determining": true
}
}
}
}
}
}
}
}
}
}
List report (global action)
...
"extends": {
"extensions": {
"sap.ui.controllerExtensions": {
"sap.suite.ui.generic.template.ListReport.view.ListReport": {
"controllerName": "my_app.ext.controller.ListReportExtension",
"sap.ui.generic.app": {
"<entity set>": {
"EntitySet": "<entity set>",
"Actions": {
"<Action 1>": {
"id" : "<id>",
"text" : "<button text>",
"press" : "<handler function>",
"global": <true|false>
},
"<Action 2>": {
...
},
...
}
...
Please note that this topic has not yet been updated with information specific to OData V4.