web dynpro: context mapping and model binding ??web dynpro: context mapping and model binding...

Download Web Dynpro: Context Mapping and Model Binding ??Web Dynpro: Context Mapping and Model Binding Matthias Weidlich Seminar System Modeling 2005 Hasso-Plattner-Institute for Software Systems Engineering

Post on 06-Mar-2018

219 views

Category:

Documents

6 download

Embed Size (px)

TRANSCRIPT

  • Web Dynpro:Context Mapping and Model Binding

    Matthias WeidlichSeminar System Modeling 2005

    Hasso-Plattner-Institute for Software Systems Engineeringmatthias.weidlich@hpi.uni-potsdam.de

    Abstract

    In this paper the main concepts and basic technologiesconcerning data management in Web Dynpro are described.After the context concept has been explained, the focusturns to the different types of dataflows in a Web Dynproapplication. Therefore the mechanisms Data Binding, Con-text Mapping and Model Binding will be discussed. Com-pleting the given impression of the link between frontendsystem and backend system, the import of models and theirconnections at runtime will be characterized.

    1. Introduction

    With the launch of the NetWeaver platform, SAPintroduces a new framework for developing browserbased user interfaces, Web Dynpro. As it claimsto be the user interface technology for all applica-tions within the scope of NetWeaver, it comprisesmany complex concepts, such as a generic, platform-independent meta model oriented on the Model ViewController (MVC) design pattern. An introductioninto these general concepts can be found in [9, 12].

    Referring to [5], Web Dynpro allows the separationof design decisions, navigation issues and data mod-elling, which includes the concepts to store and trans-port data inside an application.

    Context Mapping and Model Binding, mentionedin the title, are two mechanism for data passing in WebDynpro. Nevertheless this paper focuses not only onthese issues, but also explains the basic principles con-cerning data management. That is why the article isdivided into two parts.

    Firstly the context concept, the main concept re-garding data storage in Web Dynpro, will be dis-cussed. On account of this the utilization and thestructure including the most important properties will

    be explained. The first part ends with a short descrip-tion of the approaches for context programming.

    In the second part the focus will turn to thedataflows in a Web Dynpro application. Therefore thethree different dataflow types, Data Binding, ContextMapping and Model Binding, will be introduced. Af-ter the questions of the model origin will be answered,communication scenarios are illustrated.

    Finally the main points about dataflows in WebDynpro will be concluded.

    2. Context Concept

    2.1. Utilization of Contexts

    A Web Dynpro application consists of active parts,the controllers, and passive parts the contexts. More-over each controller, for instance a view controller ora custom controller, has its own context. Although alldata used by the controller or views is stored in thecorresponding context, another aspect is even moreimportant. Contexts are used as interfaces to pass datafrom the frontend, the user interface, to the backendsystem and vice versa. That brings us to the question,how these contexts are structured.

    2.2. General Context Structure

    Contexts are always structured as a tree, consistingof nodes (the non-leafs) and attributes (the leafs), as itis shown in the Entity Relation Model in figure 1 onthe following page. Each context has a root node,underneath the data fields are stored. Although thename implies something different, the root node is nota usual node, but a pointer that simply defines the en-try point into the tree. That is why the cardinality isunchangeable, set to 1..1 (see also 2.3). Both types ofcontext elements, subnodes and node attributes, exists

    1

  • !

    !

    Figure 1. Context Structure

    in two flavours: a model and a value flavour. The dif-ference is not only a varying set of properties. In addi-tion value nodes have no binding to the Web Dynpromodel (the model will be explained in 3.4), the typicalservices existing for a model node, like data transferto the model, are not available for the value node. Thesame term is endowed for value attributes and modelattributes.

    Since it is not possible to discuss all properties ofcontext elements within the scope of this article, in thenext part the focus will be laid on the most importantones.

    The property name should be self-explanatory, itcontains the name of the context element that have tobe unique in the whole project. As type declares thedata type of a value attribute it can be a Java NativeType. Nevertheless Java Dictionary Types1 are evenbetter to use as attribute types, due to the possibilityto attend a Data Binding.

    2.3. Cardinality and LeadSelection

    Causing the fact that the context is a data modelthat describes entities and relations, each node repre-

    1The Java Dictionary contains central, platform- and source codeindependent type descriptions, including meta data for databaseobjects and user interfaces.

    sents either an individual instance2 of an object typeor a list of instances at runtime [2]. This propertyof a node is called cardinality, which is specified viaminimal appearance .. maximal appearance andcan take on four values:

    0..1The node contains only one element instance,which have not to be instanced.

    1..1Again the node contains only one element in-stance, but this time it has to be instanced.

    0..nThe node is called multiple node and can containseveral element instances, of which none have tobe instanced.

    1..nAgain the node is a multiple node and can containseveral element instances, of which at least onehave to be instanced.

    According to the possibility to define multiple nodes,a mechanism to mark a specific element instance inthe list is necessary. For that reason each element in aninstance list belonging to a value node has a booleanproperty called leadSelection. This property can be settrue for only one element of the list at one time. Ifnothing else is specified, the first element of the list isautomatically assigned the lead selection property.

    2.4. Calculated Attributes

    A special type of value attributes are the calculatedattributes. Hence these attributes are not stored asmemory objects at runtime, they are automatically cal-culated by the Web Dynpro Runtime on demand. Thisdemand can be triggered by the Web Dynpro Runtimeor some controller coding by accessing the attribute.After setting the property calculated true, the body ofa setter- and a getter-method is generated and the de-veloper has to add the calculation part.

    A short code example for a calculated attribute canbe seen on figure 2. It shows how a full name of aperson can be calculated by simply combining the firstname and the last name.

    2To be accurate it has to be said that the individual instance isalso embedded in a singleton list.

    2

  • !""

    !#$

    %

    &

    Figure 2. Calculated Property Code Example

    2.5. Singleton Property and Supply Functions

    Another important property is the singleton prop-erty that can be found in value nodes as well as inmodel nodes. Unlike the cardinality of a node, whichdescribes the number of possible elements withinthe node, the singleton property determines whetherthese elements are set for all elements of the parentnode3 (non-singleton) or for exactly one element of theparent node (singleton) [2]. The affiliation of these sin-gleton elements is realized in the following way: thesingleton elements correspond to the parent node el-ement which is highlighted by the property leadSelec-tion (as it was described in 2.3). Therefore a change ofthe lead selection in the element list of the parent nodemakes it necessary to update the data in the singletonelements.

    For that reason a special type of controller meth-ods for filling value nodes with elements exists, theSupply Functions. These functions are called by theWeb Dynpro Runtime whenever the element list ofthe associated node is accessed. Although each nodecan have a Supply Function they are mainly used inconnection with singleton elements. The data originsused to fill the singleton elements can be various, forinstance other elements of the current context.

    2.6. Context APIs

    While Supply Functions only deal with the in-stances belonging to a context node, there also has tobe the possibility to change the structure of the con-text by programming. On account of this Web Dynproprovides two different types of Application Program-ming Interfaces (APIs).

    The first one is the set of generic APIs which areneeded for the dynamic creation of new context ele-ments at runtime. Examples for generic APIs are theglobal interfaces IWDContext (to gain access to a spe-

    3A parent node of a context element is the node, which is locateddirectly above the element in the hierarchical structure.

    cific context) and IWDNode (to modify, respectivelycreate a context node).

    The typecasted APIs, the second type of providedAPIs, are generated automatically for all statically de-fined context elements. These interfaces are type-casted, meaning that the signatures of the methodsalready contain the corresponding object types re-spectively Java Dictionary Types. The typecasted in-terfaces, for instance IContextNode (the interface tomodify a specific node) or IContextElement (to mod-ify a specific node element), are derived from theglobal interfaces.

    3. Web Dynpro Dataflows

    3.1. Overview

    In this chapter the three types of dataflows in a WebDynpro application, the Data Binding, the ContextMapping and the Model Binding, will be explained.

    Before the focus turns to the structural details therelevance of these dataflows should be motivated. Onthe one hand the Data Binding realizes the link be-tween the user interface and the data structures be-hind, in the sense of ordinary input- and output mech-anism. On the other hand it allows controlling the ap-pearance of the user interface by the data structures.The Context Mapping, which enables data to be cir-culated between contexts, is mainly used