how to extend a SAPUI5 Fiori application on both view and controller in WebIDE

119 阅读1分钟

www.evernote.com/shard/s505/…
This post consists of three parts, their titles are pretty self-explanatory.

PART I. Create a New Extension Project in WebIDE
PART II. Create a View Extension
PART III. Create a Controller Extension

PART I. Create a New Extension Project in WebIDE

Go to rde-fiori.dispatcher.neo.ondemand.com/

Create a new Extension Project.

clipboard1

Select Remote -> SAPUI5 ABAP Repository.

clipboard2

Select application from SAPUI5 ABAP repository (GM6_https would be our target system, and CRM_OPPRTNTY would be our application to create extension upon).

clipboard3

Finish up.

clipboard4

Update the Component.js due to one of the existing bug discovered by Jerry Wang (url: “/sap/bc/ui5_ui5/sap/crm_opprtnty”), then run it.

clipboard5

Here’s our familiar Opportunity application.

clipboard6

The idea is to put all the custom extension code in this extension project, and leave the standard product code untouched. Once the extension project is completed, user shall update their Fiori launchpad, to make the extension project as the entry point of the target application.

PART II. Create a View Extension

Locate the ExtensionPoint in the view where you would like to extend, take opportunityItemExtension in the S2.view.xml for example.

clipboard7

Update the extension project Component.js, add the extension information into the customizing property.

clipboard8

Create our extension view.

clipboard9

Write our extension code, we’re essentially replacing the origin list item, in order to add a new object attribute.

clipboard10

Run the extension project again, you will see the extended view ?

clipboard11

PART III. Create a Controller Extension

Same as the view extension, we’ll first locate the hook in the controller, take extHookExtendProductEntryOnAdd in the S5.controller.js for example.

clipboard12

Then, update the extension project Component.js with the controller extensions property.

clipboard13

Lastly, create and write our controller extension code.

clipboard14

Run it, bingo, when the product added, we’ll get the product name and alert it out.

clipboard15