03 0 Context at Design Time

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 16

The Context At Design Time

Contents:
 The structure of the context
 Context mapping
 Internal mapping

 SAP AG 2005, Title of Presentation / Speaker Name / 1


The Context At Design Time: Topic Objectives

After completing this topic, you will be able to:


 Understand the structure of the context
 Use the context editor
 Use internal context mapping

 SAP AG 2005, Title of Presentation / Speaker Name / 2


The Context - The Heart of a Controller

Controller Other WD
Required
Controllers Controllers
Implementation
Controller Custom
Context Standard Controller
Interface
Hook
Root Node
Methods

Instance Business
Methods Logic
(Models)

Component Other WD
Usage Components

Created by explicit declaration or coding Created by the Web Dynpro Framework (WDF)

 SAP AG 2005, Title of Presentation / Speaker Name / 3


Changing the Context

1) Open a controller (view or


custom) using the Change 2) Choose the Context tab.
option in the context menu

3) Display the Property by


selecting the CONTEXT node

 SAP AG 2005, Title of Presentation / Speaker Name / 4


Context Structure – Design Time (1)

Node

Attribute

Context Root Node


Context menu on the Context Root Node

 Context Node:
 Are arranged hierarchically and are permitted to have children
 Children of a node may be entities known as other nodes or attributes
 Metadata description declared manually or derived from a Dictionary Structure

 Context Attribute:
 Stores runtime data or references to runtime data
 Based on DDIC Types

 SAP AG 2005, Title of Presentation / Speaker Name / 5


Context Structure – Design Time (2)

Context Metadata
Node Metadata (c=cardinality, s=singleton)
Context Root (c=1..1, s=true) IF_WD_CONTEXT_NODE_INFO (interface)
FLIGHTS (c=0..n, s=true) Attribute Metadata (data type)
BOOKINGS (c=0..n, s=false) WDR_CONTEXT_ATTRIBUTE_INFO (structure)
BOOKID A node collection
CUSTOMID

CLASS
 All context nodes are collections.
PASSNAME
 A node collection is composed of
CARRID
elements, where an element is an
CONNID
aggregation of the node’s immediate
FLDATE children (attributes and/or other nodes).
PRICE  The cardinality property controls the
number of elements a node collection
may hold at runtime.
Design time
 SAP AG 2005, Title of Presentation / Speaker Name / 6
Context Structure – Runtime (1)

 All independent nodes are forced to be singletons. This is


because the context root node has one and only one element.

Context Root Node

c=1..1, s=true
= Element created by an application at runtime
Default 1 = Element created by the WDF at context initialisation time
Element

c=1..1, s=true
Node collection contains a default element.
Default 1
Element Can contain a maximum of one element.

c=0..1, s=true Independent Node


1 Node collection is initially empty.
Can contain a maximum of one element.

Independent Node

 SAP AG 2005, Title of Presentation / Speaker Name / 7


Context Structure – Runtime (2)

 All independent nodes are forced to be singletons. This is


because the context root node has one and only one element.

Context Root Node

c=1..1, s=true
= Element created by an application at runtime
Default 1 = Element created by the WDF at context initialisation time
Element = Element at the lead selection

c=1..n, s=true
Node collection contains a default element.
..n Can contain as many elements as required.
2
c=0..n, s=true Default 1
Element
..n
2
1 Independent Node
Node collection is initially empty.
Can contain as many elements as required.
Independent Node
 SAP AG 2005, Title of Presentation / Speaker Name / 8
Context Structure – Runtime (3)
Context Root
The runtime structure of the
Default
Context Metadata Element 0
context if node BOOKINGS is a
non-singleton.
Context Root (c=1..1, s=true)
FLIGHTS (c=0..n, s=true) FLIGHTS
BOOKINGS (c=0..n, s=false) CARRID ..n
CARRID
CONNID
2
BOOKID
CARRID
CONNID 1
CUSTOMID
CONNID
CLASS FLDATE
PASSNAME
BOOKINGS
CARRID
BOOKINGS BOOKID ..n
CONNID BOOKID 2
BOOKINGS CUSTOMID
BOOKID ..n
FLDATE BOOKID
BOOKID 2CUSTOMID
1
BOOKID ..nCUSTOMID
PRICE BOOKID BOOKID
2 1CUSTOMID
CUSTOMID
CUSTOMID
BOOKID 1 CUSTOMID
CUSTOMID
CUSTOMID

Design Time Runtime

 SAP AG 2005, Title of Presentation / Speaker Name / 9


Context Structure – Runtime (4)
Context Root
The runtime structure of the
Default
Context Metadata Element 0
context if node BOOKINGS is a
singleton.
Context Root (c=1..1, s=true)
FLIGHTS (c=0..n, s=true) FLIGHTS
BOOKINGS (c=0..n, s=true) CARRID ..n
CARRID
CONNID
2
BOOKID
CARRID
CONNID 1
CUSTOMID
CONNID
CLASS FLDATE
PASSNAME

CARRID

CONNID
BOOKINGS
FLDATE
BOOKID ..n
PRICE BOOKID 2
CUSTOMID
BOOKID
CUSTOMID
1
CUSTOMID

Design Time Runtime

 SAP AG 2005, Title of Presentation / Speaker Name / 10


Context Structure – Why Singleton nodes?
Context Root
Default
Element 0

Q: Why do singleton nodes exist? FLIGHTS


CARRID ..n
A: Efficiency! CARRID
CONNID
2
CARRID
CONNID 1
CONNID
FLDATE

This design of context structure both copies BOOKINGS


the way users handle business data, and
BOOKID ..n
causes the Web Dynpro application to BOOKID 2
CUSTOMID
consume significantly less memory. BOOKID
CUSTOMID
1
CUSTOMID

 SAP AG 2005, Title of Presentation / Speaker Name / 11


Supply Function
Context Root

 Context node can be assigned a supply


function
FLIGHTS
CARRID ..n
CARRID
CONNID
2
 This supply function is called by the runtime
CARRID
CONNID 1
CONNID
when the data of the context node is required
FLDATE
 Especially useful in combination with singleton
nodes

BOOKINGS
BOOKID ..n Supply function
BOOKID
CUSTOMID
2
BOOKI
CUSTOMID
BOOKINGS_READ
1
D
CUSTOMID

 SAP AG 2005, Title of Presentation / Speaker Name / 12


Context Mapping

 Context mapping is the primary mechanism


for sharing data between different controllers.

 Advantages:

 Data is automatically available to all


controllers using the mapping relationship

 Only one copy of the data is ever maintained

 Data can be mapped selectively, thus


reducing the amount of data in a controller’s
context to the minimal set required to fulfil a
task

 SAP AG 2005, Title of Presentation / Speaker Name / 13


Context Mapping

After the mapping the


mapped structure appears
in the target context

Drag and drop structure


or create a node and
define the mapping

In the property of the node the mapping path is visible

 SAP AG 2005, Title of Presentation / Speaker Name / 14


Context Mapping: Internal Mapping

View Controller Component Controller

Context Root Context Root


FLIGHTS FLIGHTS
BOOKINGS BOOKINGS

BOOKID Controller BOOKID


Usage
CUSTID Declaration CUSTID

CLASS CLASS

PASSN PASSN

CARRID CARRID

CONNID CONNID

FLDATE FLDATE

PRICE PRICE

Web Dynpro Component

Mapped node collection Node collection of mapping origin


Mapping Relationship
 SAP AG 2005, Title of Presentation / Speaker Name / 15
The Context At Design Time: Unit Summary

You should now be able to understand:


 The Structure of the Context
 Internal Context Mapping

 SAP AG 2005, Title of Presentation / Speaker Name / 16

You might also like