UI5使用Association和Aggregation描述控件之間的關係。dom
Aggregation:parent和子控件在lifecycle上存在依賴關係:component
When a ManagedObject is destroyed, all aggregated objects are destroyed as well and the object itself is removed from its parent. That is, aggregations won't contain destroyed objects or null/undefined.orm
好比UI5的轉盤控件Carousel: 一旦轉盤被析構,裏面顯示的page固然也沒有繼續存在的意義了,須要跟着被析構。blog
而Association描述了在lifecycle層面的一種soft dependency關係:ip
Managed associations also form a relationship between objects, but they don't define a lifecycle for the associated objects. They even can 'break' in the sense that an associated object might have been destroyed already although it is still referenced in an association. ci
最明顯的例子就是控件和其label的關係,好比button和label:技術上來講,能夠彼此分開獨立存在。rem
CRM的Genil model存在三種類型的relation,能夠在doman CRM_RELATION_KIND裏查看:部署
區別:get
Association: Link between any kind of objects. Can also be defined across components with root or access object as target. 依賴關係最爲loose的一種relation,能夠用來鏈接跨model之間的節點。it
Aggregation: Binds child objects to a root object. Only access and dependent objects can be aggregated. 只適用於同一模型的節點之間的關聯。
Composition: Like an aggregation, but composed child objects always exist. 特殊類型的Aggregation。目標節點的Cardinality爲1或者1..n
只有兩種:association或者composition。Composition的含義同CRM裏的aggregation,而association的含義同UI5和CRM中的association一致。
只有兩種: association或者composition。C4C的這兩種relation多了一個限制:relation的目標BO必須和源BO在同一個部署單元Deployment Unit,或者目標BO位於Foundation部署單元內。
Association的語法以下圖:
association的multiplicity只支持[0,1]或者[1,1], 若是不顯式指定,默認爲[1,1].
C4C relation的一個特點是,一旦申明瞭一個子節點以後,系統會默認生成一個對應的composition。
下圖第4行代碼會自動生成一個[0,n]的從root節點到Item節點的composition。
要獲取更多Jerry的原創技術文章,請關注公衆號"汪子熙"或者掃描下面二維碼: