Skip to Content

Can't access model class in sub-controller

Hi,

I'm faced with what seems to be an unusual problem. I'm working on a BSP appl. with MVC.

The flow is

main.do -> main.view -> detail.do & search.do. I have a model class which is instantiated in the do_request of main.do.

My need is to pass the instance of the model from the sub-controller detail.do to detail.htm. The code i'm using is

data: event type ref to cl_htmlb_event .

event = cl_htmlb_manager=>get_event( request ).

  • get reference to search_controller

main_controller ?= m_parent.

if main_controller is bound.

search_controller ?= main_controller->get_controller(

controller_id = 'Detail' ).

if search_controller is bound and event is bound and

event->id = 'search' .

data: detail_view type ref to if_bsp_page.

detail_view = create_view( view_name = 'detail.bsp' ).

  • Send model class to sub-controller 'Detail'

detail_view->set_attribute(

name = 'model_phbk'

value = <b>main_controller->m_model</b> ).

call_view( detail_view ).

************************************************

When i do a syntax check, it says that main_controller->m_model does not exist. But i have defined the same as an attribute of that controller. The interesting part is I commented the set_attribute code and debugged this portion. What i found is when i gave main_controller->m_model in the field, it showed me the instance of the model.

So <b>main_controller->m_model</b> is not recognised when I code and check, but is recognised in debug. Why is this happening?

Thanks & Regards,

Sumith.

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 07, 2005 at 12:19 PM

    Hi Sumith,

    why don't you use

    main_controller->get_model( 'the_model_id' )

    to get a reference to the main controller's model.

    Regards,

    Sebastian

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Sumith Rajagopalan

      Sumith,

      are you sure your main controller's attribute <i>m_model</i> is <i>public</i>. If it is not the compiler complains of course whereas in the debugger there is a setting that lets you look into private members of a class. Just a quick thought..

      Regards,

      Sebastian

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.