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

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

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 to make thedata persistent, due to the limited lifetime of view con-trollers. An example for such a usage can be found in[5]. Moreover the Model Binding connects the inter-nal data structures of a Web Dynpro application withthe model that represents the backend system (see also3.4).

    Furthermore it is necessary to envision the struc-ture of a typical application which is shown in theblock diagram in figure 3. The Web Dynpro Runtimeembeds the application, which consists of agents, forinstance a view controller, a custom controller and amodel agent. To keep the diagram concise, the appli-cation consists of only one controller of each type andsome parts (e.g. interface controller and componentcontroller) are not even shown at all.

    Additionally there is a big storage containing sev-eral smaller storages. As it was already mentioned,every controller has its own context, in this case theview controller context and the custom controller con-text. Moreover the view layout contains the proper-ties of the user interface elements, while the structureof the model is depicted in 3.4. Pointed out by thefigure, the big unnamed storage is fragmented by thefour smaller storages. Accordingly the imagination

    3

  • !"

    # $

    % %

    &

    '

    (

    ) *

    Figure 3. Overview of Dataflows

    4

  • of multiple interfaces, used to access the big storage,is appropriate. Several numbered storage elementsare available in more than one storage hence the fournamed storages overlap in some areas. Concerningthe dataflows these are the interesting parts, that willbe introduced in the following sections.

    3.2. Data Binding

    The first dataflow to discuss is the Data Binding in-volving the view layout and the view controller con-text. Data Binding allows the use of context attributesof the view controller as properties of user interface(ui) elements. Referring to figure 3 the storage ele-ments with the number 2, 3 and 4 participate in theData Binding, while the storages with the number 1and 5 are ui element properties, respectively contextelements that have not been bound. On account of thebinding any user change to the ui element properties,e.g. the text property of an edit field, is immediatelyvisible in the context. Due to the assignment of thesame data storage, there is no necessity of data trans-port.

    Figure 4. Data Binding

    As it is shown in figure 4 the Data Binding canbe defined with value attributes as well as model at-tributes if the attributes type is a Java Dictionary Type.In the specific case that the ui element property is afield of values (e.g. the entries in a table) the parentnode of the bound attribute has to be a multiple node,regarding 2.3. If a single property value is bound toan attribute of a multiple node, the leadSelection high-lights the value that has to be shown.

    3.3. Context Mapping

    The mechanism used to pass data from one contextto another is called Context Mapping. As context ele-ments are in general only visible for the controller the

    context belongs to, they can be regarded as local vari-ables. After a Context Mapping has been defined be-tween two context elements located in different con-texts, one and the same context element is visible inboth contexts. Similar to the Data Binding a ContextMapping does not require any data transport, becausethe same storage is assigned for mapped elements. Infigure 3 the Context Mapping involves the view con-troller context and the custom controller context. Thestorage elements with the number 5 and 8 are contextelements that have not been mapped. In contrast, theelements with the number 3, 4, 6 and 7 are mapped,whereas the elements 3 and 4 are also bound with aData Binding as it is described in 3.2.

    Figure 5. Context Mapping

    The figure 5 shows that a Context Mapping on theone hand can be defined either between value nodesor between model nodes, but not between a singlevalue node and a single model node. On the otherhand value attributes can be mapped only to value at-tributes. For model attributes the same rule is applied.Additionally the following constraint has to be satis-fied: a mapping between the parent nodes of two at-tributes is a precondition for a mapping between theseattributes.

    Moreover Context Mapping is a directive relation.Although the direction has no impact on data changes,because it is irrelevant in which context the changes

    5

  • are made, modifications of the mapping relation haveto be done at the context in which the mapping rela-tion starts. Consequently the context that is mappeddoes not even have any knowledge about the map-ping at all.

    Nonetheless it is necessary to define a usage rela-tion between the controllers, whose contexts shouldparticipate in a Context Mapping.

    3.4. Web Dynpro Model

    Figure 6. Web Dynpro Model

    Before the focus turns to the third type of dataflow,the Model Binding, the Web Dynpro model itselfshould be discussed. The model is a data structurethat represents the data and the functionality of thebackend, for instance a web service provider or aABAP 4 backend server. As it can be seen in fig-ure 6, the model consists of model classes which ontheir part contain other model classes and model at-tributes. The model classes are Java classes which canbe grouped in executable and non-executable classes.Nevertheless they all have to implement the CommonModel Interface (CMI), an interface that affects mainlydata management and event han...

Recommended

View more >