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的原创技术文章,请关注公众号"汪子熙"或者扫描下面二维码: