Sunteți pe pagina 1din 16

The Context At Design Time

Contents:
The structure of the context Context mapping Internal mapping

SAP AG 2005, Title of Presentation / Speaker Name / #

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 / #

The Context - The Heart of a Controller


Controller
Implementation Context
Root Node

Required Controllers Controller Interface

Other WD Controllers
Custom Controller

Standard Hook Methods Instance Methods

Business Logic (Models)

Component Usage

Other WD Components

Created by explicit declaration or coding


SAP AG 2005, Title of Presentation / Speaker Name / #

Created by the Web Dynpro Framework (WDF)

Changing the Context


1) Open a controller (view or custom) using the Change option in the context menu 2) Choose the Context tab.

3) Display the Property by selecting the CONTEXT node

SAP AG 2005, Title of Presentation / Speaker Name / #

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 / #

Context Structure Design Time (2)

Context Metadata
Context Root (c=1..1, s=true)
FLIGHTS (c=0..n, s=true) BOOKINGS (c=0..n, s=false) BOOKID CUSTOMID CLASS

Node Metadata (c=cardinality, s=singleton) IF_WD_CONTEXT_NODE_INFO (interface) Attribute Metadata (data type) WDR_CONTEXT_ATTRIBUTE_INFO (structure) A node collection

PASSNAME
CARRID CONNID FLDATE

PRICE

All context nodes are collections. A node collection is composed of elements, where an element is an aggregation of the nodes immediate children (attributes and/or other nodes). 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 / #

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 Default Element 1 = Element created by an application at runtime = Element created by the WDF at context initialisation time

c=1..1, s=true Default Element c=0..1, s=true 1 1

Node collection contains a default element.

Can contain a maximum of one element.

Independent Node

Node collection is initially empty.

Can contain a maximum of one element.


Independent Node
SAP AG 2005, Title of Presentation / Speaker Name / #

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 Default Element 1 = Element created by an application at runtime = Element created by the WDF at context initialisation time = Element at the lead selection

c=1..n, s=true ..n 2 c=0..n, s=true ..n 2 1 Independent Node Default 1 Element

Node collection contains a default element. Can contain as many elements as required.

Node collection is initially empty. Can contain as many elements as required.

Independent Node
SAP AG 2005, Title of Presentation / Speaker Name / #

Context Structure Runtime (3)


Context Root

Context Metadata
Context Root (c=1..1, s=true) FLIGHTS (c=0..n, s=true) BOOKINGS (c=0..n, s=false)

Default Element

The runtime structure of the context if node BOOKINGS is a non-singleton.

FLIGHTS
CARRID CARRID 2 CONNID CARRID CONNID 1 CONNID FLDATE
..n

BOOKID
CUSTOMID CLASS PASSNAME CARRID CONNID FLDATE PRICE

BOOKINGS
BOOKID ..n BOOKID 2 CUSTOMID BOOKINGS BOOKID ..n BOOKID 1 CUSTOMID BOOKID 2 CUSTOMID BOOKID ..n CUSTOMID BOOKID 1 BOOKID 2 CUSTOMID CUSTOMID BOOKID 1 CUSTOMID CUSTOMID CUSTOMID

BOOKINGS

Design Time
SAP AG 2005, Title of Presentation / Speaker Name / #

Runtime

Context Structure Runtime (4)


Context Root

Context Metadata
Context Root (c=1..1, s=true) FLIGHTS (c=0..n, s=true) BOOKINGS (c=0..n, s=true)

Default Element

The runtime structure of the context if node BOOKINGS is a singleton.

FLIGHTS
CARRID CARRID 2 CONNID CARRID CONNID 1 CONNID FLDATE
..n

BOOKID
CUSTOMID CLASS PASSNAME CARRID CONNID FLDATE PRICE

BOOKINGS
BOOKID ..n BOOKID 2 CUSTOMID BOOKID 1 CUSTOMID CUSTOMID

Design Time
SAP AG 2005, Title of Presentation / Speaker Name / #

Runtime

Context Structure Why Singleton nodes?


Context Root
Default Element 0

Q: Why do singleton nodes exist?


A: Efficiency!

FLIGHTS
CARRID CARRID 2 CONNID CARRID CONNID 1 CONNID FLDATE
..n

This design of context structure both copies the way users handle business data, and causes the Web Dynpro application to consume significantly less memory.

BOOKINGS
BOOKID ..n BOOKID 2 CUSTOMID BOOKID 1 CUSTOMID CUSTOMID

SAP AG 2005, Title of Presentation / Speaker Name / #

Supply Function
Context Root

Context node can be assigned a supply function


FLIGHTS
CARRID CARRID 2 CONNID CARRID CONNID 1 CONNID
..n

This supply function is called by the runtime when the data of the context node is required
Especially useful in combination with singleton nodes

FLDATE

BOOKINGS
BOOKID ..n BOOKID 2 CUSTOMID BOOKI 1 CUSTOMID D CUSTOMID

Supply function BOOKINGS_READ

SAP AG 2005, Title of Presentation / Speaker Name / #

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 controllers context to the minimal set required to fulfil a task

SAP AG 2005, Title of Presentation / Speaker Name / #

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 / #

Context Mapping: Internal Mapping


View Controller Component Controller

Context Root
FLIGHTS BOOKINGS

Context Root
FLIGHTS

BOOKINGS
Controller Usage Declaration BOOKID CUSTID CLASS PASSN CARRID CONNID FLDATE PRICE

BOOKID
CUSTID CLASS PASSN CARRID CONNID FLDATE PRICE

Web Dynpro Component


Mapped node collection Mapping Relationship
SAP AG 2005, Title of Presentation / Speaker Name / #

Node collection of mapping origin

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 / #

S-ar putea să vă placă și