Skip to Content
author's profile photo Former Member
Former Member

MVC Controller Communication

Hi Guys,

after a short glance at the MVC tutorial on help.sap.com i want to create my own application.

I have one main contoller, two sub-controller of which one has a model calss connected that gets data from function modules.

One subcontroller calls different views that gets data from function module calls.

My problems are:

1) how can i get two subcontroller to communicate with each other? is there a direct way without main controller possible and if not, can i manage the communication. is it possiblejust with DO_HANDLE_DATA and DO_REQUEST?

2) does it always have to be the way with data collection via model class that the result of a function from the model is stored first in an attribute of model class and then has to be set as page attribute of the called view?

Can anyone please help me as there is no clear help from sap...

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 05, 2005 at 04:31 AM

    hi,

    For 1st problem.

    you can use application class variables to communicate b/w two controllers.

    For your 2nd problem.

    in MVC its the controller which is basically controlling the flow of application hence for sending data to your view you have to send via controller using set page attributes.

    However you can also pass data directly to the view without intervention of controller i.e straight from one view to other or from model directly to view.

    for this you have to make use of application class. and just use application class attributes and access them througout application as global variables or set view attributes via them. you can access them as:

    application->variable_name

    hope this helps you, else reply,

    Regards,

    Hemendra

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 05, 2005 at 04:44 AM

    Hi Christian,

    You can use model class to communicate between two subcontrollers. for this you have to instanciate your model at appriate places in both sub controllers. in this case you will be using only model class other than DO_HANDLE_DATA and DO_REQUEST.

    Ya in 2nd case you are right you get attribute values through model class, But for this you need not to set each attribute in page attribute of view. Just set your model with TYPE REF TO..[your model class].And then you are able to retrieve value by <%=model->attribute%>.

    I hope this helps you.

    Regards

    Amit

    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.