SAP Smart Template(现在叫Fiori Element了)进行扩展的一些例子-阿里云开发者社区

开发者社区> 努力滴码农> 正文

SAP Smart Template(现在叫Fiori Element了)进行扩展的一些例子

简介: SAP Smart Template(现在叫Fiori Element了)进行扩展的一些例子


This document describes the APIs which can be used by a break-out developer who enhances an App based on Smart Templates using break-outs.

Note that this applies for controller and for view extensions.

Content of the API

Actually the API consists of several pieces that will be discussed in this paragraph.

Standard UI5

In coding break-outs you can use the standard UI5 programming API. However, this should be handled with care.

When you have defined a view extension, then you can access and modify the properties of all ui elements defined within these extensions (e.g. change the visibility programmatically).

However, access to ui elements not defined within own view extensions is not allowed.

Moreover, you should not use the services provided by the namespace, since these services are intended to be used by freestyle-apps or are used within the generic Smart Template implementation. Also do not use any services provided by the namespace sap.ui.generic.template directly. Having two layers (Smart Template coding and break-out coding) access these services in parallel might lead to unwanted side-effects.


Several models (instances of sap.ui.model.Model) are attached to the Smart Template artifacts.

OData model

The most prominent is the default model, which is in fact the OData model specified in the manifest.

You can use this model for data-binding in your own view extensions.

Accessing the model programmatically (via standard UI5 API-methods) should be done with care, since side-effects may interfere with Smart template coding also working on this model.

This applies in particular to function imports. Therefore, you should rather use method invokeActions of the extensionAPI (see below) in order to call function imports.

UI model

Each view has an own model attached carrying the name ui. This model can be used in view and controller extensions for reading purposes.

Currently, this model contains three properties:

· enabled

· editable

· createMode

All of them have boolean values.

The first one indicates whether active ui elements (like buttons) should currently be enabled.

The second one indicates whether input fields or similar ui elements should currently be in an editable state.

The third one indicates whether the ui currently displays an entity which is about to be created (no active version exists yet).

Note that it is also possible to register for changes of these properties. However, the logic at which point in time these properties are set and reset may still be changed.

It is strictly forbidden to perform any changing operations on the properties of the ui model.

Smart Template Private model

There exists an additional model which is attached to each view containing properties that are used for Smart Template internal purposes.

It is strictly forbidden to access this model in any way.[1]

Application specific models

You may want to define your own JSON model and attach it to UI elements.

If the model is attached to a UI element only existing within the scope of a break-out, this is no problem.

Models that are attached on a more global level (e.g. to the whole view) should only be used if necessary. In this case you should use a name containing your own namespace to clearly separate from models defined by other parts of the framework.

Implementation of extension hooks

Each template potentially already provides a set of extension hooks which can be implemented by the break-out developer in his controller break-out.

Currently these break-outs are not documented in the jsdoc. Therefore, a short overview is given here.

Actually, only the ListReport template possesses any extension hooks right now:


This is an init method which may be used for initialization purposes in case you have created your own filterbar extension.

Note that oEvent.getSource() provides access to the SmartFilterbar at this point in time.


These methods allow the break-out developer to store and restore the state of any ui elements added via extensions.

For the get-method oCustomData is an empty object. It is the task of this method to add any state to this object that needs to be restored when having navigated away from this page and returned later.

The restore-Method will get this object into its hands. It is the task of this method to restore the information that can be found in oCustomData.

Note: For technical reasons the oCustomData-object is currently not empty but possesses an attribute _editStateFilter. Do not access this attribute in any way. Future implementations will get rid of this.


This method allows the break-out developer to handle the standard onBeforeRebindTable-event of the SmartTable.


Note: This extension hook is still under discussion. If you’re the owner of an app using this extension hook, please contact the smart template team.

API methods

When coding the implementation of an extension hook or an event handler used in a view extension you can use the public methods of sap.ui.core.mvc.Controller as usual.[2]

In addition you may want to access some service provided by the Smart Template framework.

From the controller you can access these services via


This way you obtain an object which is specific to the template you are currently enhancing.

More precisely, for the list report you get an instance of sap.suite.ui.generic.template.ListReport.extensionAPI.ExtensionAPI, for the object page you get an instance of sap.suite.ui.generic.template.ObjectPage.extensionAPI.ExtensionAPI[4].

Any other methods or properties of the controller (in particular any components with a name starting with ‘_’) should be considered private and therefore not be used.

Moreover: Do not create any instances of classes in namespace sap.suite.ui.generic.template on your own. They are not intended for public use.

Coding sample

 * Assumed use case: When price is changed to a critical value (more than 1000) an email should be prepared to be send.
 * This should not happen for changes in the draft but only after activation has been successfully processed in the
 * backend.
(function() {
      "use strict";
      function onAfterActivate(oEvent) {
              * AfterActivate event is raised at the end of frontend processing for activation. The object handed into the
              * handler contains a promise that is resolved after a successful response from the backend
             oEvent.activationPromise.then(function(oResponse) {
                   if ( > 1000) {
                         sap.m.URLHelper.triggerEmail(null, "critical price change", "changed price of " +
                                      + " to " + + " " +;
      sap.ui.controller("DemoPublicAPI.ext.controller.DetailsExtension", {
             onInit: function() {

[1] So do not access any model besides the default model and the model with name ui unless you have attached it to the ManagedObject yourself.

[2] Please remember the general remarks about using standard ui5 programming APIs stated above.

[3] this being a reference to the controller

[4] Note that you should not rely on the names of these classes in your coding, as they still may be changed. However, the set of methods provided by these objects will only be extended in a compatible way.


在应用中,有时会遇到用户询问如何使单台云服务器具备多个公网IP的问题。 具体如何操作呢,有了NAT网关这个也不是难题。
26797 0
如果在创建实例时没有设置密码,或者密码丢失,您可以在控制台上重新设置实例的登录密码。本文仅描述如何在 ECS 管理控制台上修改实例登录密码。
10095 0
虽然0.0.0.0/0使用非常方便,但是发现很多同学使用它来做内网互通,这是有安全风险的,实例有可能会在经典网络被内网IP访问到。下面介绍一下四种安全的内网互联设置方法。 购买前请先:领取阿里云幸运券,有很多优惠,可到下文中领取。
11819 0
windows server 2008阿里云ECS服务器安全设置
最近我们Sinesafe安全公司在为客户使用阿里云ecs服务器做安全的过程中,发现服务器基础安全性都没有做。为了为站长们提供更加有效的安全基础解决方案,我们Sinesafe将对阿里云服务器win2008 系统进行基础安全部署实战过程! 比较重要的几部分 1.
9161 0
阿里云安全组设置详细图文教程(收藏起来) 阿里云服务器安全组设置规则分享,阿里云服务器安全组如何放行端口设置教程。阿里云会要求客户设置安全组,如果不设置,阿里云会指定默认的安全组。那么,这个安全组是什么呢?顾名思义,就是为了服务器安全设置的。安全组其实就是一个虚拟的防火墙,可以让用户从端口、IP的维度来筛选对应服务器的访问者,从而形成一个云上的安全域。
7503 0
阿里云ECS云服务器初始化是指将云服务器系统恢复到最初状态的过程,阿里云的服务器初始化是通过更换系统盘来实现的,是免费的,阿里云百科网分享服务器初始化教程: 服务器初始化教程方法 本文的服务器初始化是指将ECS云服务器系统恢复到最初状态,服务器中的数据也会被清空,所以初始化之前一定要先备份好。
7365 0
购买阿里云ECS云服务器后如何登录?场景不同,云吞铺子总结大概有三种登录方式: 登录到ECS云服务器控制台 在ECS云服务器控制台用户可以更改密码、更换系统盘、创建快照、配置安全组等操作如何登录ECS云服务器控制台? 1、先登录到阿里云ECS服务器控制台 2、点击顶部的“控制台” 3、通过左侧栏,切换到“云服务器ECS”即可,如下图所示 通过ECS控制台的远程连接来登录到云服务器 阿里云ECS云服务器自带远程连接功能,使用该功能可以登录到云服务器,简单且方便,如下图:点击“远程连接”,第一次连接会自动生成6位数字密码,输入密码即可登录到云服务器上。
22412 0
+ 订阅