14.01.2020 Views

ABAP_to_the_Future

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

12

Web Dynpro ABAP and Floorplan Manager

12.1.3 Controller

A controller is any sort of computer program that knows about one or more models

and one or more views; it’s a sort of broker that handles communication

between them. Inside a controller, you need to code business logic to decide if a

certain view should be used to display the data of a certain model. When a view

sends back a message saying the user has done something, you need to add code

to the controller so that it can decide if the model needs to know this, or if the

controller can deal with the input itself (e.g., an instruction to display exactly the

same data in a different format can be handled by the controller simply calling up

another view without having to bother the model). The controller must be careful

never to let the view and the model know of each other’s existence (otherwise the

entire universe will explode—or something almost as terrible).

The controller concept in WDA is even more complicated than you might expect,

because there isn’t only one controller but a number of them. The thing to

remember is that out of all the myriad controllers you may see, the component

controller is the head honcho, numero uno,the leader of the pack, the king of the

hill, and the undisputable top cat.

The controllers in WDA are generated automatically: the component controller at

the start and other controllers as and when the windows and views are created. It

is also possible to create additional controllers manually.

What is the “component” that is being controlled? A component can be thought

of as the equivalent of the module pool program (it isn’t really, but it’s close

enough). If you treat the two terms as interchangeable, then the component controller

becomes the program controller, an d the waters are slightly less muddy.

The component controller can be accessed by all the views and can talk back to

them, as might be expected; any other controllers knocking around are just willing

accomplices.

There are “view controllers” and “window controllers,” but they are not controllers

in any meaningful sense of the wo rd, because such controllers are one with

their respective windows and views and never talk to the model like proper controllers

do.

Thus, as mentioned earlier, just because something is called a controller, walks

like a controller, and quacks like a controller, you shouldn’t treat it like a controller

if it isn’t one; make sure all contro ller-type tasks are delegated to a real controller.

514

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!