Entering content frame

Procedure documentation Creating Main Controller bookshop.do Locate the document in its SAP Library structure

Use

The main controller is what the URL calls directly from the browser. Method DO_REQUEST of the controller class is always executed.

Prerequisites

The small MVC example Model View Controller Tutorial in Creating Controllers describes how you create a controller with the corresponding controller class. Proceed in exactly the same way.

Procedure

Give the controller class (derived from CL_BSP_CONTROLLER2, this is set automatically) any name; we selected CL_BSP_MVCTUT for this example.

Now overwrite method DO_REQUEST as follows:

method DO_REQUEST .

  data: main_view type ref to if_bsp_page.

  dispatch_input( ).

  main_view = create_view( view_name = 'default.htm' ).

  call_view( main_view ).

endmethod.

As long as a controller does not call a view, you will never receive a response in the browser.

A view object is created in the method and assigned to view default.htm. The view is then called.

Call dispatch_input() is required in the main controller so that the data that may be entered in the browser can be assigned to the relevant controllers. The main controller must take on this task. The method is a component of class CL_BSP_CONTROLLER2 and therefore the controller class that is derived from it.

This graphic is explained in the accompanying text

Now create view default.htm: Creating Main View default.htm

 

 

Leaving content frame