Skip to Content
author's profile photo
Former Member

Main Controller Id

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?.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

5 Answers

  • Best Answer
    Posted on Jan 27, 2005 at 01:51 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Jan 27, 2005 at 01:18 PM

    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'

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Jan 27, 2005 at 02:22 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Jan 27, 2005 at 05:54 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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.

  • Posted on Jan 28, 2005 at 08:19 AM

    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

    Add comment
    10|10000 characters needed characters exceeded