Skip to Content
Former Member
Oct 08, 2004 at 12:53 PM

how to parameterize initialization of controllers


Say we have a controller <i>A_ctrl</i> and a model <i>A_model</i>. When initializing <i>A_ctrl</i> we would like to create/register the model and initialize it, something like:

A_model ?= create_model( class_name = '/path/toclass' model_id = me->model_id ).
A_model->set_something( me->some_parameter ).

Now, as one can see the initialization is parameterized with <i>me->model_id</i> and <i>me->some_parameter</i> ; since <i>do_init()</i>'s signature is empty, instance variables of <i>A_ctrl</i> are used.

However, how do we get the initialization parameters into <i>A_ctrl</i> (in non-BSP ABAP-OO the normal constructor would do the job)? In the view via <bsp:call>, <bsp:parameter> it is to late, because initialization has already taken place. If we don't initialize the model and leave this job (i.e. calling the methods <i>set_something()</i> etc.) to the creator of <i>A_ctrl</i> (probabely the super controller) itself, we would actually hold the creator of an object responsible for its correct/complete initialization - a job that objects typically are supposed do themselves (in 'normal' OO this is the one right to exist for constructors (right?)).

How is this dilemma solved?