Creating a Custom Controller Context and Binding it to the Model

The custom controller FlightListCust is responsible for retrieving flight data from an SAP system, so it needs to be able to map the corresponding input and output for the flight model. To establish this correspondence between the custom controller and the model, you will create an appropriate controller context and then bind the context nodes to the model structure. In this way, you can ensure that the model data is stored and manipulated in a central location.

Prerequisites

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

Procedure

Adding a model to the Web Dynpro component

       1.      In the project structure, expand the tree up to the node Web Dynpro ® Web Dynpro Components ® FlightListComp.

       2.      Select the node Used Models and open the context menu.

       3.      Choose  Add.

       4.      In the list that appears, select the model FlightModel and confirm by choosing OK.

By doing so, you specify that all views and controllers of FlightListComp have a dependency relationship with the model FlightModel.

Creating a context for the custom controller

1.       In the project structure, double-click the name of the custom controller (in this case, FlightListCust).

2.       Choose the Context tab if necessary.

3.       Open the context menu for the root node  Context and choose the option New ® Model Node.

4.       Enter the name Bapi_Flight_Getlist_Input for the model node and choose Finish.

5.       From the context menu for the model node that you have just created, choose Edit Model Binding

6.       Choose the model class Bapi_Flight_Getlist_Input, followed by Next.

7.       Activate the following entries: Destination_From and Destination_To. Expand Output and activate Flight_List. Choose Finish.

The Developer Studio refreshes the context tree appropriately.

In this way, you have completed specification of all the context nodes for the input and output data. You will need this context later for the SearchView and the ResultView.

8.       Save your work by choosing the icon  (Save All Metadata) from the toolbar.

Result

Using the model definition as your starting point, you have created a context for the custom controller FlightListCust and bound the appropriate context nodes for the input and output structures to the corresponding model nodes.

Next step:

Mapping View Context Elements to Custom Context Elements