To add a controller extension in SAP Fiori, you can follow these steps:
- Open the SAP Web IDE or Eclipse IDE and create a new SAPUI5 project.
- In the project, create a new JavaScript file for the controller extension. The file name should follow the naming convention "{originalControllerName}.controller.js".
- In the extension file, define a new controller that extends the original controller. For example, if the original controller is named "MyController", the extension file should contain the following code:
- javascriptCopy codesap.ui.define([
- "sap/ui/core/mvc/Controller"
- ], function(Controller) {
- "use strict";
- return Controller.extend("my.namespace.MyController", {
- // add your extension code here
- });
- });
- In the original view XML file, add a reference to the new extension controller. For example, if the original controller is named "MyController", the extension controller should be named "MyControllerExtension". The XML should contain the following code:
- phpCopy code<mvc:View controllerName="my.namespace.MyController">
- <mvc:content>
- <!-- your view content here -->
- </mvc:content>
- <mvc:controllerExtensions>
- <mvc:ExtensionController name="my.namespace.MyControllerExtension" />
- </mvc:controllerExtensions>
- </mvc:View>
- In the extension controller, you can add new functionality by defining new methods or overriding existing ones. You can also access the original controller by calling the "this.base()" method.
- Save your changes and deploy the SAPUI5 project to your SAP system.
That's it! Your SAP Fiori application should now use the new controller extension.
Call us on +91-84484 54549
Mail us on contact@anubhavtrainings.com
Website: Anubhav Online Trainings | UI5, Fiori, S/4HANA Trainings
Comments
Post a Comment