cancel
Showing results for 
Search instead for 
Did you mean: 

Main Controller Id

Former Member
0 Kudos

I have in a BSP application several controllers, despite I have one of them as the "Main" controller(the application starts from there) any of the others have been defined as subcontrollers in DO_INIT method of "Main", how can I get the Id of the other controllers?.

Accepted Solutions (1)

Accepted Solutions (1)

rainer_liebisch
Contributor
0 Kudos

Hi Ruben,

Craig is right, but there is also another possibility to create a subcontroller (implicitely):

You can call in the main view:


<bsp:call comp_id = "hd"
          url     = "header.do" />

I've used the same names as Craig for id and name.

Regards,

Rainer

Answers (4)

Answers (4)

rainer_liebisch
Contributor
0 Kudos

Hi Ruben,

I think I know now what's your question.

Let's say you have a main controller and 2 subcontroller

with the id subc1 and subc2. You want to access the attributes of subc1 in subc2.

Then put in Do_Request of subcontroller2 the following code:


c_main type ref to cl_bsp_controller2,
c_sub type ref to cl_subc1.

c_main ?= m_parent.
c_sub  ?= c_main->get_controller( 
                    controller_id = 'subc1' ).

attrib = c_sub->attr_of_subc1.

You can get the attributes via the main controller which is accessible with m_parent.

Hoping this helps you and solves your question.

Regards,

Rainer

Former Member
0 Kudos

I don't want to create the controllers they are already created, I just need to access to attributes from one controller to another but I don't have the ID of the target controller and any controller was created in the DO_INIT method of any controller.

Former Member
0 Kudos

Ruben, you'll have to forgive us we don't seem to be understanding what it is your asking.


 header_ctr ?= create_controller( 
        controller_name  = 'header.do'
        controller_id    = 'hd' ).  

 <bsp:call comp_id = "hd"          
           url     = "header.do" />

In both cases the controller is called "hd", in your main controller you call dispatch_input() in your DO_REQUEST then in each controller you can process the data available under DO_REQUESTR or DO_HANDLE_EVENT. If the data is from a subcontroller and is an inputfield called "sid" then it would be available with the name "hd_sid" as the subcontroller name is appended to the front of the form element name then you just get the value of that form element.

So now that we've all shot around in the dark how about you given us a bit more info on what you are trying to do and then we can get more specific.

Former Member
0 Kudos

Could it be that Ruben wants to know, which controller is processed and how he can identify that:

Like(for example):

data:

event type ref to cl_htmlb_event,

tableView_event type ref to cl_htmlb_event_tableView.

event = CL_HTMLB_MANAGER=>get_event( runtime->server- >request ).

tableView_event ?= event.

if tableView_event->id eq 'tv_lagerbest'.

...

With this i know that the ID of a tableView is 'tv_lagerbest'.

I am not really sure, if that could be also the question of Ruben.

Thorsten

Former Member
0 Kudos

I might be thinking to simple here but you give the controller it's id.


  model ?= create_model( class_name = 'ZSC_CL_M_SOLUTION_CENTRAL'
                  model_id = 'mf' ).

  header_ctr ?= create_controller( controller_name = 'header.do'
                                   controller_id   = 'hd' ).

  header_ctr->set_model( model_id = 'mf'
                   model_instance = model ).

I gave my header_ctr Controller the ID 'hd'