2016-02-24 20 views
0

這是我如何建立新的控制:Sapui5用我的新CONTROLE在XML

https://sapui5.hana.ondemand.com/sdk/#docs/guide/91f0a8dc6f4d1014b6dd926db0e91070.html

sap.ui.somelib.SomeControl.extend("my.OwnControl", { 
     ... 
     init: function() { 
      if (sap.ui.somelib.SomeControl.prototype.init) { // check whether superclass implements the method 
        sap.ui.somelib.SomeControl.prototype.init.apply(this, arguments); // call the method with the original arguments 
      } 

      //... do any further initialization of your subclass... 
     } 

可以使用一些CONTROLE在我的XML看法?

+0

我用符號與依賴注入等: 代碼('sap.ui.define([ \t「SAP /米/ ObjectListItem「 ],function(ObjectListItem){ \t」use strict「; \t返回ObjectListItem.extend( 「my.newListItem」,{ ') 和以xml: 代碼('<芯:查看的xmlns:我= 「我」> <定製:SystemStatusListItem標題=「膝上型「intro =」{Description}「id =」tem1「/>') – migacz1125

回答

0

當定義這樣的控制: sap.ui.core.Control.extend("my.Square", ...

,並宣佈XML命名空間 xmlns:my="my"

你可以用你的控制是這樣的: <my:Square text="test" size="100px"/>

但只有當你也聲明你的控制作爲現有模塊: jQuery.sap.declare("my.Square"); (最後一部分在其他答案中缺失)

這裏是一個運行示例從文檔中的 「廣場」 的控制: http://jsbin.com/zuxebev/1/edit?html,output

+0

但是如果你使用的是AMD風格的語法,對嗎?我的意思是'sap.ui.define(['sap/ui/core/Control'],function(Control){return Control.extend(「my.Square」,{...})});' – Marc

+0

正確...但你仍然可以'jQuery.sap.declare(「my.Square」);'使其工作。但讓我感到驚訝的是,爲什麼需要從XMLView的角度來看。 – akudev