14 - wd_dataflow context mapping and model binding

Download 14 - WD_dataflow Context Mapping and Model Binding

Post on 07-Apr-2018

216 views

Category:

Documents

0 download

Embed Size (px)

TRANSCRIPT

  • 8/6/2019 14 - WD_dataflow Context Mapping and Model Binding

    1/23

    Matthias Weidlich

    Web Dynpro:Context Mapping & Model Binding

    Seminar System Modeling

    08.06.05

  • 8/6/2019 14 - WD_dataflow Context Mapping and Model Binding

    2/23

    HPI, Seminar System Modeling - SS2005 / 2

    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

  • 8/6/2019 14 - WD_dataflow Context Mapping and Model Binding

    3/23

    HPI, Seminar System Modeling - SS2005 / 3

    Context Concept: Usage of Contexts

    contexts are the main concept for storingand 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 correspondingcontroller

    a context represents a hierarchical datamodel

    a context describes entities and their

    relations, so it can be compared to an ERModel

  • 8/6/2019 14 - WD_dataflow Context Mapping and Model Binding

    4/23

    HPI, Seminar System Modeling - SS2005 / 4

    Context Concept: General Structure

    a context is always

    structured as a tree,

    consisting of nodes

    and attributes

    each context has a root node, underneaththe data fields are stored

    nodes represent data structures, attributes

    represent data elements

    Context Element

    Subnode

    name cardinality selection singleton

    Root Node cardinality = 1..1

    Value Node

    leadSelection

    Model Node modelClass

    Context

    Node Attribute name readOnly

    Value Attribute calculated type

    Model Attribute

    consists

    of

    "consists

    of

  • 8/6/2019 14 - WD_dataflow Context Mapping and Model Binding

    5/23

    Context Concept: Cardinality

    Boat

    Controller

    b3

    Red

    b2

    Green

    Sailor

    s1 05.05. 07.05.

    s5 12.06. 13.06.

    Sailor

    redb3

    greenb2boat_colorboat_ID

    Johns5

    Jims1sailor_namesailor_ID

    13.06.12.06.s5b207.05.05.05.s1b2

    rented tillrented fromsailor_IDboat_ID

    Lending

    rented from

    rented till

    Boat

    boat_ID

    color

    Sailor sailor_ID

    name

  • 8/6/2019 14 - WD_dataflow Context Mapping and Model Binding

    6/23

    HPI, Seminar System Modeling - SS2005 / 6

    Context Concept: Cardinality (2)

    node elements represent either

    an individual instance

    of an object type

    or a list of instances

    this property of a nodeis called cardinality

    cardinality is specified

    via min appearance ..max appearance:

    (0)1..1: the node

    contains only one

    element instance which

    has (not) to be instantiated0(1)..n: the node can contain multiple element instances (at least one)

    leadSelection marks one element in an element list

    Element in

    Design Time

    1:1 Node cardinality = 1..1

    0:1 Node cardinality = 0..1

    1:n Node

    cardinality = 1..n

    0:n Node cardinality = 0..n

    Element in

    Runtime

    Node

    Element0..1

    List ofNode

    Elements

    1..n

    0..n

    consists

    of

    can be

    mapped to

  • 8/6/2019 14 - WD_dataflow Context Mapping and Model Binding

    7/23

    HPI, Seminar System Modeling - SS2005 / 7

    Context Concept: Type and Calculated

    type declares the data type of the attribute (type can be Java NativeType, 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

    demandon demand: the attribute is accessed by a layout controller or somecontroller coding

    body of setter- and getter- method is generated automatically, thedeveloper has to code the calculation part

    code example for calculated property:

    java.lang.String getUserFullName (

    IPrivateFormView.IUserDataElement element) {

    //@@beginreturn element.getFirstname() + + element.getLastname();

    //@@end

    }

  • 8/6/2019 14 - WD_dataflow Context Mapping and Model Binding

    8/23

    HPI, Seminar System Modeling - SS2005 / 8

    Context Concept: Singleton

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

    Boat

    Controller

    b3

    Red

    b2

    Green

    Sailor

    s1 05.05. 07.05.

    s5 12.06. 13.06.

    Sailor

    State5

  • 8/6/2019 14 - WD_dataflow Context Mapping and Model Binding

    9/23

    HPI, Seminar System Modeling - SS2005 / 9

    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 contextelements

    method signatures contain the corresponding object typesuse interfaces that are derived from the global interfaces, e.g.IContextNode, INode

    Context Concept: Supply Functions & Context Progr.

  • 8/6/2019 14 - WD_dataflow Context Mapping and Model Binding

    10/23

    Data Flows in a Web Dynpro Application

    data binding:link betweenview layout andview controllercontext

    context mapping:link between twoglobal controllercontexts orbetween globalcontroller

    context and view

    controllercontext

    model binding:link betweenglobal controller

    context and WebDynpro Model

    Web Dynpro Application

    View

    Controller

    Model

    Custom

    Controller

    Model

    Agent

    Web Dynpro Runtime

    Custom Controller

    Context

    View Controller

    Context

    View Layout

    to backend system

    to

    presentation

    server

  • 8/6/2019 14 - WD_dataflow Context Mapping and Model Binding

    11/23

    Data Flows: Data Binding

    data binding:link betweenview layout andview controllercontext

    1:context elementthat has notbeen bound

    2:UI element that

    has not beenbound

    3, 4, 5:UI element /context element

    that has beenbound

    Web Dynpro Application

    View

    Controller

    Model

    Custom

    Controller

    Model

    Agent

    Web Dynpro Runtime

    Custom Controller

    Context

    View Controller

    Context

    View Layout

    to backend system

    to

    presentation

    server

    2 3 4 5

    1

  • 8/6/2019 14 - WD_dataflow Context Mapping and Model Binding

    12/23

    HPI, Seminar System Modeling - SS2005 / 12

    Data Flows: Data Binding (2)

    properties of the user interface elements can bebound to attributes respectively nodes of a view context

    context attributes have to be Java Dictionary Types, as Java Native Typescannot be bound

    any user changes to the UI element properties in the view are immediatelyvisible 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 multiplenode (cardinality = 0/1 . . n)

    is a single value bound to an attribute of a multiple node,leadSelection marks the value to show

    UI ElementUI Element

    Property

    Context Attribute

    Value Attribute

    Node Attribute

    is bound toconsists of

  • 8/6/2019 14 - WD_dataflow Context Mapping and Model Binding

    13/23

    Data Flows: Context Mapping

    context mapping:link between twoglobal controllercontexts orbetween globalcontroller

    context and viewcontrollercontext

    1, 2:

    context elementthat has not beenmapped

    3, 4, 5, 6:context element

    that has beenmapped

    Web Dynpro Application

    View

    Controller

    Model

    Custom

    Controller

    Model

    Agent

    Web Dynpro Runtime

    Custom Controller

    Context

    View Controller

    Context

    View Layout

    to backend system

    to

    presentation

    server

    2 3 4

    1

    5 6

  • 8/6/2019 14 - WD_dataflow Context Mapping and Model Binding

    14/23

    HPI, Seminar System Modeling - SS2005 / 14

    Data Flows: Context Mapping (2)

    locally defined attributes areonly visible for thecorresponding controller

    mapped attributes are visible atboth ends of the mapping

    again: the same data storage isassigned, no data transport is

    necessary

    constraint:

    attribute 1 can only be mappedon attribute 2, if one of the

    parent nodes of attribute 1 ismapped on one of the parentnodes of attribute 2

    Nodeconsists

    of

    Value Node

    Model Node

    is mapped to

    AttributeValue Attribute

    Model Attribute

    is mapped to

    is mapped to

    is mapped to

    consists

    of

  • 8/6/2019 14 - WD_dataflow Context Mapping and Model Binding

    15/23

  • 8/6/2019 14 - WD_dataflow Context Mapping and Model Binding

    16/23

    Data Flows: Model Binding

    model binding:link betweenglobal controllercontext and WebDynpro Model

    1:model elementthat has not beenbound

    2:context element

    that

Recommended

View more >