cancel
Showing results for 
Search instead for 
Did you mean: 

MVC: Controller called twice in application

Former Member
0 Kudos

I have a situation that I am hoping is not that strange to some of you. The app that I am working on is fairly simple. A table is created using user-input from an input field and a function module in the controller class. This table is then sent to the view and used to populate a tableview. Once a user has chosen a row and clicked submit, the controller is called again. What is supposed to happen, of course, is that I use the row that was selected against the previously created internal table. My problem is that the data in the internal table is lost by the time the user clicks the submit button.

After a little debugging, I've learned that even on the original painting of the view, the controller is called a second time. When the controller is called a second time (without any user interaction yet) all data is 'refreshed.' The view reverts to intitial and my internal tables are cleared.

There is only one controller and one view in this application. Main.do and Main.htm.

Does anyone have an idea as to why the dispatch_input in Main.do would be called a second time, even after the view has been painted on screen and the user has yet to submit anything?

I appreciate any guidance you can give!

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello Theresa Dancy,

Welcome to SDN Forums...

I suggest you to use the <b>Application Class</b> for storing values.

The main function of Application Class is a BSP Application is to store values in it.

There can be only one application class for one bsp application.

You can find the application class field in the properties of the BSP Application.

Refer this link for more information on Application Class...

http://help.sap.com/saphelp_nw04/helpdata/en/21/8cec3ada87e076e10000000a11405a/content.htm

Reward points for useful answer by clicking the star on the left side of the screen.

Regards,

Maheswaran.B

Message was edited by: Maheswaran B

Former Member
0 Kudos

Are you using any model to the controller?

I would suggest have one if you are not using. When you are updating the tableview call the MAC and store the data in an internal table. Always call the internal table of the MAC on event.

Hope this helps you.

Regards,

Shailaja

Former Member
0 Kudos

Thank you, Shailaja. I did try using a model for the controller. I may be doing it wrong - I'll give it another look. It's strange, though. I do have another MVC project I created myself that has no model and there has been no 'refreshing' problems with that one.

Still - this particular project may need a model. Again, I'll take another look at the model I'm using.

Thank you for the suggestion!