Class CL_BSP_CONTROLLER2 is used to create controllers and Components. Every controller class automatically inherits all methods and attributes from this central basic class.
If the basic class of your controller class displays CL_BSP_CONTROLLER instead of CL_BSP_CONTROLLER2, change the inheritance hierarchy accordingly.
Class CL_BSP_CONTROLLER2 enables you to:
· Retain a list of sub-controllers
· Create unique IDs for the sub-controllers, where the sub-controller is assigned the controller ID prefix
· Use models
· Forward data to the correct controller as well as fill model classes (if they exist)
Below you can find an overview of all methods in a controller class. Process Flow provides details on the most important methods.
The individual methods can be separated into different categories:
DO_REQUEST is the central method in a controller class.
You must overwrite this method.
In DO_REQUEST you specify the request processing, that is, this method is called for every request. This method does the “main work”; in particular it should branch to the correct view.
DO_REQUEST can be used in two different areas:
· If it is the top-level controller of a component, then this method handles both input and output processing.
· If it is a sub-controller of a component, then this method only handles output processing.
You should overwrite these methods in order to determine input processing.
Method |
Description |
DO_HANDLE_DATA |
Reacts to user
input. |
DO_HANDLE_EVENT |
Reacts to user
input. Exactly one view controller is called to handle the event, which contains an event such as a save button, for example. |
DO_FINISH_INPUT |
Ends the input processing. |
You can overwrite these methods in order to determine input processing.
Method |
Description |
DO_INIT |
This method is called once at the start and is used for initialization. This method behaves like a constructor method. |
DO_INITATTRIBUTES |
This method is called with every request and is used to initialize the attributes. The parameters are read from the request. In this method, you can also execute initializations that are required for each request. You can also use this method to set additional attributes. This method is not absolutely necessary, since you can use DO_REQUEST to solve everything that you can (theoretically) handle here. |
You can call these methods:
Method |
Description |
CREATE_VIEW |
Creates or fetches a view instance Use either the name of the view, or the object navigation.
A view must always belong to the same BSP application as its controller. |
CALL_VIEW |
Calls the request handler of the view instance. |
CREATE_CONTROLLER |
Creates or fetches a controller instance |
CALL_CONTROLLER |
Calls the request handler (method DO-REQUEST) of the controller instance. |
GET_ATTRIBUTE |
Returns the
specified page attributes. |
GET_LIFETIME |
Returns the lifetime of this page (only for the top-level controller) |
GET_PAGE_URL |
Returns the URL of the page or the current controller |
SET_ATTRIBUTE |
Sets the specified
page attributes. |
SET_LIFETIME |
Changes the lifetime of this page (only for the top-level controller) |
TO_STRING |
Creates a formatted string |
WRITE |
Writes a formatted string in the output |
GET_OUT |
Fetches the current output writer |
SET_MIME_TYPE |
Changes the MIME type of the page or the content type of the header field |
INSTANTIATE_PARAMETER |
Instantiates the parameter from the request using the request data |
SET_CACHING |
Changes the caching values There are two types of caching: · Browser cache · Server cache
You can only use
limited caching here. |
DISPATCH_INPUT |
Dispatches the input processing (only for the top-level controller). For each input,
DISPATCH_INPUT calls the
correct methods in the correct sequence.
This method does not have any attributes. |
GET_ID |
Calculates the ID from the specified ID and the component ID |
SET_MODEL |
Creates and registers a model instance |
CREATE_MODEL |
Creates and registers a model instance |
GET_CONTROLLER |
Fetches a sub-controller |
CONTROLLER_SET_ACTIVE |
Sets a controller
to active/inactive. |
DELETE_MODEL |
Deletes a model instance |
FILL_MODEL_DATA |
Fills the model data |
DELETE_CONTROLLER |
Deletes a sub-controller |
GET_MODEL |
Fetches a model instance |
IS_TOPLEVEL |
Is this controller a top (main) controller (0: no, 1: yes)? |
IS_NAVIGATION_REQUESTED |
Has a controller requested a navigation (0: no, 1: yes)? |
These methods are provided as part of the framework and are only included here for the sake of completeness. They are not usually relevant for application development.
Method |
Description |
IF_BSP_DISPATCHER~REGISTER |
Registers a sub-components |
IF_BSP_CONTROLLER~FINISH_INPUT_PROCESSING |
Processes or dispatches: end of input processing. |
IF_BSP_CONTROLLER~FILL_VALUES |
Processes or dispatches: handling values |
IF_BSP_CONTROLLER~HANDLE_EVENT |
Processes or dispatches: Handle event |
GET_FIELD_COMPONENT |
Finds components for a field name |
GET_FIELD_MODEL |
Finds model for a field name |
Methods DO_DESTROY and SUBSCRIBE are not relevant.