cancel
Showing results for 
Search instead for 
Did you mean: 

DO_HANDLE_EVENT in sub-controller?

Former Member
0 Kudos

Hi there,

Please can someone help me....this main / sub-controller way of doing things is great BUT I'm battling to get the DO_HANDLE_EVENT to fire in my sub-controllers. How do you specify a controller to be a sub-controoler when you create it? I'm busy doing a BSP application and have all the code in the right place but can't get the DO_HANDLE_EVENT in the sub-controllers to fire at all (but the application probably doesn't even see them as sub-controllers!!!)

I've got a "default.htm" page that is my "main view"....it has the following code in it...

<htmlb:tray id      = "documentTypeTray"

                title = "Document Type"

                design = "form"

                width = "100%"

                isCollapsed = "false" >

            <bsp:call url = "findDocument.do"

                    comp_id = "findDocument" />

</htmlb:tray>

Now if you can imagine the view called by "findDocument.do" has a button on it and when the user clicks on it I want the code to break in the sub-controllers DO_HANDLE_EVENT BUT it always breaks in the main controllers DO_HANDLE_EVENT....

I've obviously lost the plot somewhere....please help!!!

Regards

Lynton

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Lynton,

   Have you write a "dispatch_input( )." at the do_request of the main controller??

former_member215843
Active Participant
0 Kudos

Hi Lynton,

normally the do_handle_event_method of the subcontroller should be called.

But in your case we have to search for the reason, why it is not called.

I do not think that you forgot to call dispatch_input(), because otherwise the method would not be called in the main controller.

The most likely reason is that the subcontroller is not instantiated (check the table m_subcontrollers). Perhaps because the application is stateless (you can switch it on the application property page)?

If you have a stateless application, and you want to dispatch the input to the subcontroller, you must create the subcontrollers before handling the input.

I think the best way is to separate the creation of the subcontrollers from the rendering call.

So, how to do?

For each subcontroller, place a statement like

  my_subcontroller = create_controller( controller_id = 'finddocument'

                                  controller_name = 'findDocument.do' ).

into the DO_INIT method of the calling controller (here: main controller).

This reasures that the subcontroller is always created.

Then you may call some methods of the new created controller, e.g. for initialization of parameters.

Within the view you may omit the URL parameter of the <bsp:call> tag, because it is already known.

I would recommend to create the subcontrollers directly by the calling controller in any case, even if the application is stateful.

Regina

Former Member
0 Kudos

Hi there,

Thanks for the reply.....I do have the "dispatch_input()" in my main controller....must be something else...

Thanks anyway

Former Member
0 Kudos

Hi Regina,

Thanks so much for the reply...much appreciated!!

I did call "dispatch_input()" in the main controller and it still didn't work....I did debug the application at runtime and the sub-controllers where NOT in table m_subcontrollers...

And yes, I've just realised that the application was stateless....seems when you make a new BSP application it is stateless by default....

You other explanations make lots of sense as well.....I have used create_controller before but not in the DO_INIT method of the maincontroller...

Thanks again for your help

Lynton