You are on page 1of 23

Web Dynpro: Context Mapping & Model Binding

Seminar System Modeling 08.06.05

Matthias Weidlich

Agenda
Context Concept usage of contexts general structure context properties supply functions and context programming Data Flows in a Web Dynpro Application overview data binding context mapping model binding model import connection to model at runtime In a Nutshell References

HPI, Seminar System Modeling - SS2005 / 2

Context Concept: Usage of Contexts


contexts are the main concept for storing and passing data in Web Dynpro each controller has its own context all data used in controllers or views is stored in the context of the corresponding controller a context represents a hierarchical data model a context describes entities and their relations, so it can be compared to an ER Model

HPI, Seminar System Modeling - SS2005 / 3

Context Concept: General Structure


a context is always structured as a tree, consisting of nodes and attributes
Context Element Context Root Node
cardinality = 1..1

each context has a root node, underneath the data fields are stored

Subnode
name cardinality selection singleton modelClass

"consists of

Model Node Value Node


leadSelection

nodes represent data structures, attributes represent data elements

consists of

Node Attribute
name readOnly

Model Attribute Value Attribute


calculated type

HPI, Seminar System Modeling - SS2005 / 4

Context Concept: Cardinality


Boat boat _ID color Lending rented from rented till

boat_ID b2 b3

boat_color green red boat_ID b2 b2 sailor_ID s1 s5

sailor_ID s1 s5 rented from 05.05. 12.06.

sailor_name Jim John rented till 07.05. 13.06.

Sailor sailor_ID name

Boat Sailor b2 s1 05.05. 07.05.

Controller

Green

s5

12.06.

13.06.

b3 Red

Sailor

Context Concept: Cardinality (2)


node elements represent either an individual instance Element in of an object type Design Time or a list of instances
1:1 Node

can be mapped to

Element in Runtime

this property of a node is called cardinality

cardinality = 1..1

0:1 Node
cardinality = 0..1

Node 0..1 Element consists of

cardinality is specified 1..n 1:n Node via min appearance .. cardinality = 1..n List of Node max appearance: 0..n Elements 0:n Node (0)1..1: the node cardinality = 0..n contains only one element instance which has (not) to be instantiated 0(1)..n: the node can contain multiple element instances (at least one) leadSelection marks one element in an element list
HPI, Seminar System Modeling - SS2005 / 6

Context Concept: Type and Calculated


type declares the data type of the attribute (type can be Java Native Type, but should be a Java Dictionary Type) calculated = true means the attribute is not stored as a memory object, but will be automatically calculated by the Web Dynpro Runtime on demand on demand: the attribute is accessed by a layout controller or some controller coding body of setter- and getter- method is generated automatically, the developer has to code the calculation part code example for calculated property: java.lang.String getUserFullName ( IPrivateFormView.IUserDataElement element) { //@@begin return element.getFirstname() + + element.getLastname(); //@@end }
HPI, Seminar System Modeling - SS2005 / 7

Context Concept: Singleton


singleton = true means that the elements of the relevant node are instantiated for only one element of the parent node (leadSelection)

Boat

State

Sailor b2 s1 05.05. 07.05.

Controller

Green

s5

12.06.

13.06.

b3 Red

Sailor

HPI, Seminar System Modeling - SS2005 / 8

Context Concept: Supply Functions & Context Progr.


Supply Functions: special type of controller methods for creating context attributes in value nodes method body with user coding area is automatically created often used in connection with singleton nodes context programming: generic APIs
needed for the dynamic creation of new context elements at runtime use global interfaces, e.g. IWDContext, IWDNode, IWDNodelement

typed APIs
typed APIs are automatically created for statically defined context elements method signatures contain the corresponding object types use interfaces that are derived from the global interfaces, e.g. IContextNode, I<NodeName>Node

HPI, Seminar System Modeling - SS2005 / 9

Data Flows in a Web Dynpro Application


to backend system

data binding: link between view layout and view controller context context mapping: link between two global controller contexts or between global controller
to presentation server

Web Dynpro Application Model Model Agent

Custom Controller

Custom Controller Context

View Controller Context View Controller View Layout

context and view controller context model binding: link between global controller context and Web Dynpro Model

Web Dynpro Runtime

Data Flows: Data Binding


to backend system

data binding: link between view layout and view controller context 1: context element that has not been bound

Web Dynpro Application Model Model Agent

Custom Controller

Custom Controller Context

View Controller Context to presentation server 1 View Controller View Layout 2 3 4 5

2: UI element that has not been bound

3, 4, 5: UI element / context element that has been bound

Web Dynpro Runtime

Data Flows: Data Binding (2)


Context Attribute consists of UI Element UI Element Property is bound to Value Attribute Node Attribute

properties of the user interface elements can be bound to attributes respectively nodes of a view context context attributes have to be Java Dictionary Types, as Java Native Types cannot be bound any user changes to the UI element properties in the view are immediately visible in the context as the same data storage is assigned, no data transport is necessary if the UI element property is a field of values (e.g. a table), the bound node has to be a multiple node (cardinality = 0/1 . . n) is a single value bound to an attribute of a multiple node, leadSelection marks the value to show
HPI, Seminar System Modeling - SS2005 / 12

Data Flows: Context Mapping


to backend system

context mapping: link between two global controller contexts or between global controller context and view controller context

Web Dynpro Application Model Model Agent

Custom Controller

Custom Controller Context

View Controller Context to presentation server View Controller View Layout

1, 2: context element that has not been mapped 3, 4, 5, 6: context element that has been mapped

Web Dynpro Runtime

Data Flows: Context Mapping (2)


is mapped to

locally defined attributes are only visible for the corresponding controller
Value Node

mapped attributes are visible at both ends of the mapping again: the same data storage is assigned, no data transport is necessary constraint: attribute 1 can only be mapped on attribute 2, if one of the parent nodes of attribute 1 is mapped on one of the parent nodes of attribute 2

Node Model Node

consists of

is mapped to is mapped to

consists of

Value Attribute Attribute Model Attribute

is mapped to
HPI, Seminar System Modeling - SS2005 / 14

Data Flows: Context Mapping (3)

mapping is a directive relation: direction is irrelevant for data changes changes of the mapping have to be done at the context where it starts a usage relation between two controllers is a precondition for context mapping multiple mapping creates data chains between multiple contexts
HPI, Seminar System Modeling - SS2005 / 15

Data Flows: Model Binding


to backend system

model binding: link between global controller context and Web Dynpro Model 1: model element that has not been bound

Web Dynpro Application Model Model Agent 1

Custom Controller

Custom Controller Context

View Controller Context to presentation server View Controller View Layout

2: context element that has not been bound 3, 4, 5: context element / model element that has been bound

Web Dynpro Runtime

Data Flows: Model Binding (2)


Web Dynpro model: data structure that represents the data and functionality of the backend
Model

Model Element belongs to

Model Class
name

Executable Model Class

all model classes have to implement the Common Model Interface (CMI) CMI affects data management and event handling access to CMI classes: with generic methods with typed getter- and setter methods
HPI, Seminar System Modeling - SS2005 / 17

Non Executable Model Class

consists of

Model Property
name type

Data Flows: Model Binding (3)


Context Element Context Model Node is bound to Model Element

Model Class consists of Model

Context Model Attribute

Model Attribute

constraint: a context model attribute can only be mapped on a model attribute, if one of the parent nodes of the context model attribute is mapped on one of the parent classes of the model attribute
HPI, Seminar System Modeling - SS2005 / 18

Data Flows: Model Import


to Web Dynpro Runtime Models
R

Model Agent

Import Wizard

UML Web Dynpro Model (XMI) Webservice Model (WSDL)

Java Bean Model

RFC Model

Model Data

supported model types: UML Web Dynpro Model in the XMI format webservice description as WSDL Java Bean model Remote Function Call (RFC) model import wizard generates the classes out of the model

HPI, Seminar System Modeling - SS2005 / 19

Data Flows: Connection to Model (J2EE based)


R

J2EE Backend Server


(RMI)

Backend Data

J2EE Web Dynpro Runtime

Model Agent

Webservice Provider
(SOAP)

Backend Data

ABAP Backend Server


(SAP Java Connector)

Backend Data

Model Data

J2EE based Web Dynpro Runtime communication: to webservice via SOAP to J2EE backend server via Remote Method Invocation (RMI) to ABAP backend server by using the SAP Java Connector (SAP JCo)
SAP JCo is a middleware component that supports ABAP calls JAVA and JAVA calls ABAP
HPI, Seminar System Modeling - SS2005 / 20

Data Flows: Connection to Model (ABAP based)


R

Webservice Provider ABAP Web Dynpro Runtime


R

(SOAP)

Backend Data

Model Agent
R

ABAP Backend Server


(RFC, BAPI)

Backend Data

Model Data

ABAP based Web Dynpro Runtime communication: again: to webservice via SOAP to ABAP backend server directly by calling RFCs and BAPIs
access to SAP Business Objects is gained by standardized methods: Business Application Programming Interfaces (BAPIs) Remote Function Calls (RFCs) are a SAP standard for communication between applications on SAP systems as well as non-SAP systems

HPI, Seminar System Modeling - SS2005 / 21

In a Nutshell
contexts are the main concept for data management in Web Dynpro a context is a data model data flows in Web Dynpro: data binding links properties of user interface elements and context attributes context mapping links context elements model binding links context elements and elements of the model

HPI, Seminar System Modeling - SS2005 / 22

References
Web Dynpro Overview, McNulty, SAP AG, 2003 Creating your first Web Dynpro Application, SAP Online Help, SAP AG 2004 Creating an Email client using Web Dynpro, SAP Online Help, SAP AG 2004 Java-Programmierung mit dem SAP Web Application Server, Kessler, Tillert, Dobrikov, Galileo Press, Bonn 2005 Introduction to Web Dynpro, SAP Developer Network, www.sdn.sap.com Web Dynpro Architecture, SAP Library, www.help.sap.com Business Application Programming Interfaces, tse - technologieberatung und systementwicklung, Hamburg 2005, http://www.tsehamburg.de/Papers/SAP/sapBAPI.html SAP BAPI und SAP JCo, Horn, 2005, http://www.torstenhorn.de/techdocs/sap-bapi.htm Application Server, Web Application Server, Web Services, SOAP, Java, Horn, 2005, http://www.torsten-horn.de/techdocs/applicationserver.htm Wiederverwendbare Software (Web Dynpro), Tillert, 2004, www.sap.info The new face of SAP - Web Dynpro, Winkler, 2004, http://www.oio.de/webdynpro-the-new-sap-face.htm

HPI, Seminar System Modeling - SS2005 / 23