Mapping View Context Elements to Component Context Elements

In the last section, a structure for context model elements was created in the context of the component controller. This structure is bound to generated model classes. These model classes contain the data required for sending the e-mail as well as the return data belonging to the response of the Web service.

To be able to access this context structure even outside of a view context, the concept of Context Mapping is now applied.  You will learn how to map context elements of a view onto the appropriate context elements of the component controller.  The context elements of the view context reference merely to the context elements defined in the component controller, which themselves in turn reference to the actual business data in the model (more detailed: to the model-objects).

Prerequisites

·         The structure of your project WebDynpro_EmailWS is currently displayed in the Web Dynpro Explorer.

Procedure

To declare the context mapping between the view controller and the component controller you again use the Data Modeler.

Defining a Context Mapping in the Data Modeler

The Web Dynpro tools enable you to map a context node defined in the context of the view EmailFormView to a node in the context of the component controller. The context elements still missing in the node of the view context are automatically added and mapped to their respective match in the component context. In addition, the Controller Usage of the component controller needed for the context mapping is declared in the view controller.

The context elements mapped onto one another do not have to have the same name.

...

                            a.      Open the Data Modeler for the Web Dynpro component EmailWSComponent.

                            b.      In the left toolbar, choose the icon Create a data link.

                            c.      Begin above the rectangle EmailFormView and left-click. Do this without releasing the mouse button.

                            d.      Draw a line to the Component Controller rectangle and release the left mouse button.

                            e.      Drag the model node WebServiceEmail in the context of the component controller to the root node of the view controller context, and drop it.

                              f.      In the dialog box that appears, select the model node WebServiceEmailand choose Next.

                            g.      In the final dialog box, the context mapping declared between the two model nodes WebServiceEmail is displayed graphically:

 

Afterwards, the model node – together with the further context elements – is mapped to the original context in the component controller.

Result

You have created the necessary view context and mapped it to the component context you created previously. You are now in a position to bind UI controls such as input fields to the corresponding context elements.

Next Step:

Creating the Action SendEmail