Skip to Content

When do subcontroller classes die?

I have a question concerning the lifetime of controller class instances.

I have a view called root.bsp, where I create one out of two subcontrollers depending on a variable.

<% IF controller->myVar = 1.%>
    <bsp:call url="c1.do" comp_id = "c1" />
<% ELSE. %>
    <bsp:call url="c2.do" comp_id = "c2" />
<% ENDIF.%>

c1.do has a controller class called CL_1.

At first, myVar is 1, so c1 is called. Now, in CL_1 I set myVar to 2, so in the next request, c2 will be called. I would assume that the instance of CL_1 now will be destroyed because it is not used anymore. However, when I call c1.do later, CL_1 will still have the attribute values from the previous time.

Why is the controller class instance not removed after the corresponding controller/view is not shown anymore?

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    Posted on Oct 17, 2005 at 08:09 AM

    This has nothing to do whether a controller is used (shown, for the view) or not, but simply if the application is stateless or stateful.

    Are you using a stateful application?

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 17, 2005 at 08:15 AM

    Hi Daniel

    Since your application is stateless i'd assume your subcontroller dies with page change (Check Controller method set_lifetime).

    Did u try give both controllers the same comp_id? They may overwrite each other this way...

    Cheers

    Daniel

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 19, 2005 at 11:10 AM

    Hi Daniel,

    have a look at the methods of class CL_BSP_CONTROLLER2, there's a method called delete_controller (that's the asnwer to your how-question). You should know by yourself when you want to call it. I don't know the circumstances.

    Regards,

    Rainer

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.