Skip to Content
avatar image
Former Member

Context mapping

Hi all,

Can any one of you please define context mapping

Regards

Vikas

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Dec 03, 2007 at 07:28 AM

    Hi,

    Context mapping is the mechanism by which information can be shared between the contexts of different controllers. Usually, these controllers live within the same component, but context mapping can also cross a component boundary. The context node that will be mapped to some other node is known as the “mapped node”, and the context node acting as the data source is known as the “mapping origin”.

    Before context mapping can take place, the controller in which the mapped node lives must declare the use of the controller in which the mapping origin lives.

    Caveat Confector: Remember that a view controller’s context is always private and a custom controller’s context is always public. Therefore, for information to be shared between a custom controller and a view controller, the view controller must declare the use of a custom controller – not vice versa!

    This feature is a deliberate design decision that was taken to prevent a custom controller becoming dependent upon the functionality and data within a view controller. The view controller should be dependent upon the functionality provided by the custom controller.

    Important: When a mapping relationship is set up between two nodes in different contexts, then the mapped node ceases to maintain its own element collection, and instead, references the element collection of the mapping origin. Any changes made to the data in the mapped node actually update the element collection of the mapping origin. It does not matter which node you update, only the element collection of the mapping origin is ever manipulated.

    Since a mapped node does not maintain its own element collection, no runtime data is stored within a mapped node.

    It is important to understand that for a mapping relationship to exist, both contexts must have a defined node object. That is, if the context of a view controller contains a value node called SalesOrders, and this is mapped to a value node of the same name in the parent component controller, then each context will have a separate node object called SalesOrders. What is mapped is a reference to the element collection, not a reference to the context node itself. See the section on Problems with binding UI elements to context nodes (page 73) for details of the error messages that can arise from this fact.

    Selection mapping

    Since a context node maintains two cardinality properties (one for the element collection, and one for the selected elements), it is possible to map not only the element collection, but also the selection of elements within that collection. When context mapping is used, the mapped node will always have its element collection mapped to the mapping origin. But you have the choice of whether you want to map the selected nodes as well.

    If you choose not to map a node’s selection, then two independent selection lists will be maintained; one will be the list of selected elements in the mapping origin, and the other will be the list of selected elements in the mapped node. If, for instance, a view controller contains a mapped node that points to a node in the component controller, then the selection will typically not be mapped. This is because you will probably want the node selection in the view controller to reflect the user’s interaction with the displayed data, rather than a selection made for programmatic reasons within the component controller.

    Normal mapping

    Unless otherwise specified, all context mapping relationships lie within the boundaries of a single Web Dynpro component. This immediately makes all mapping relationships “internal” to a single component.

    The commonest example of this situation is the one where a view controller needs to gain access to the information in the component controller. After the component controller has been declared as a required controller of the view controller, a mapped node can be defined in the view controller that points to a mapping origin in the component controller.

    In general, once a custom controller has been declared as being required by any other controller, the nodes of its context become available to act as mapping origin nodes. This statement also holds true if a parent component has declared the use of a child component. All the nodes in the context of the child component’s interface controller can now act as mapping origin nodes.

    External mapping

    However, there are certain situations in which a mapping relationship needs to be defined, but the identity of the mapping origin is unknown at the time the mapped node is created. This type of situation exists when the mapped node and the mapping origin lie on different sides of a component boundary.

    When writing a reusable component, it is perfectly feasible to define a mapped node in the context of the interface controller that has, as its mapping origin, a node in some context of the parent. In this situation, the mapped node lies in the interface of the child component and the mapping origin lies across a component boundary in some other, as yet undefined, parent component.

    This situation is known as “external” mapping.

    At the time the child component is being written, it is impossible to establish exactly which node in the parent controller will act as the mapping origin - the parent component may not have been written yet! All that can be said is that a mapping origin is required to complete the mapping relationship, and that it will lie outside the boundary of the current component.

    Defining the exact identity of the mapping origin is now postponed until the child component is declared for use by a parent component. This is now the point in time at which the parent component must supply the identity of the node that will act as the mapping origin. Only now can the mapping relationship be considered fully established.

    This immediately leads to the conclusion that the node nominated to act as the mapping origin for an externally mapped node, is specific to the single usage instance of the child component. If you create multiple instances of the same child component, then each external mapping relationship can be satisfied by different nodes in the parent component.

    Important: There is a special property that exists only for context nodes of a component interface controller. This is the isInputElement property, and it controls whether the context node will be externally mapped or not. If isInputElement is set to true, then the node will be mapped to a mapping origin in some other component.

    Consider the following two situations in which parent and child components share information via a mapping relationship. We have two components, and , that will function as parent and child respectively. I.E. in both situations, will be regarded as the child of .

    1. contains a mapped node in its component interface controller that has the isInputElement property set to true. This immediately indicates that the node acting as the mapping origin lies outside . The identity of this node cannot be determined until declares a usage instance of , and identifies a usage specific node to act as the mapping origin. 2. both contains a mapped node and creates a usage instance of . The mapping origin will lie in the interface controller of . Since the usage of must be declared when is written, ’s interface now lies within the scope of , and can be fully established when is written.

    Situation 1 uses external mapping.

    Situation 2 uses normal (or internal) mapping.

    General points about external mapping

    1. An externally mapped node must live within the context of a component interface controller, and have its isInputElement property set to true.

    2. External context mapping is only possible for independent nodes of a component interface controller, not independent attributes.

    3. When a parent component declares the use of the child component, any externally mapped nodes in the child component’s interface controller must have their mapping references established. This is an extra configuration step during the component usage declaration.

    4. Since external mapping relationships are usage specific, it is entirely possible for there to be different mapping relationships for each usage instance of the child component.

    Regards

    Ayyapparaj

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 03, 2007 at 07:18 AM

    Hi vikas,

    A mapping can be defined between two global controller contexts, or from a view context to a global controller context.This is context mapping.

    Karthik.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 03, 2007 at 07:25 AM

    Hi,

    Context mapping helps in having a single copy of your context(ie reference) across the controllers where it has been mapped. This enables automatic data transfer across controllers and you don't have to code to copy the values from one context to another.

    Regards,

    Murtuza

    Add comment
    10|10000 characters needed characters exceeded