cancel
Showing results for 
Search instead for 
Did you mean: 

Coupling between component controller and view controller

Former Member
0 Kudos

Hello,

I have seen some discussions in this forum regarding the possibilities of calling / triggering a view controllers's method from a component controller's method; obviously the Web Dynpro framework only provides for the other direction (view ctrl -> comp ctrl) via handle <i>wd_comp_controller</i>.

Some people proposed raising events in the comp controller and catching these in the view controller, others pointed out that any dependance of a view controller on a component controller would violate MVC principles.

Now, I can't see why a tighter coupling (in both ways) between controllers within one component would harm MVC in any way. So I suggest to "register" a view controller in the pertaining component controller if necessary:


...
this_controller = wd_this->wd_get_api( ).
wd_comp_controller->register_view_ctrl_XYZ( this_controller ).
...

This way the component controller can save the reference and later call any method on it. What do you think, does anything argue against this practice?

Regards,

Sebastian

Accepted Solutions (1)

Accepted Solutions (1)

anand_nidamanuru
Active Participant
0 Kudos

Hi Sebastian,

I wouldn't try to explain whether it is violating the MVC principles or not.

Can you please explain how to call methods of view using the view controller?

have you tried using an example???

I want to give a small example which I think is a basic disadvantage of calling View methods from component controller.

Suppose I have 30 methods in a view and such 7 views in a component (I think this is a very common example).

Till now one is very clear that if I have a method in view, it will be called at maximum by other methods with in the view. That means at any point of time, my search is limited to 30 methods.

Now if component controller can also call my search will become horrible and spread to 210 methods, unless otherwise, you are very good at naming attributes and wont make the mistake of assigning attributes wrongly.

Imagine the effort if the outside components also access these methods through interface.

Also I dont think that the webdynpro phase model can support this way of calling view methods. You might be successful once, but then you are trying to open a can of worms.

This is my way of thinking...

Also, it would be great if you can tell me whether you are successful in calling views methods or not???

Thanks,

Anand

Former Member
0 Kudos

Hi Anand,

thanks for your answer. As for your note regarding a possible large number of methods in a view-controller I partly see your point - my suggestion would in a way make the view-ctrl's methods public to the comp-ctrl.

Since we are only talking about dependencies <i>within</i> one component I guess this should be tackled be designing small(er) components though. I think one component with 7 views and 30 methods each is not a good example; I'd expect a considerable number of those methods to belong to a model (behind the assistance-class facade) and not to the views.

Last points:

1) yes, the way proposed in my posting - get reference to view with this_controller = wd_this->wd_get_api( ) and 'registering' to comp-ctrl with wd_comp_controller->registerViewXYZ(this_controller) - I can call methods on the view-ctrl afterwards.

2) The webdynpro phase model - good point, I guess you're right, it is violated. Maybe that already kills the idea (!?) Still I'd be thankful if any of the "original" developers could comment on this topic..

Regards,

Sebastian

anand_nidamanuru
Active Participant
0 Kudos

Hi Sebastian,

Your comments

"my suggestion would in a way make the view-ctrl's methods public to the comp-ctrl.

Since we are only talking about dependencies within one component I guess this should be tackled be designing small(er) components though. I think one component with 7 views and 30 methods each is not a good example; I'd expect a considerable number of those methods to belong to a model (behind the assistance-class facade) and not to the views."

Here itself you are taking assumptions, designing smaller component, phase model etc. while providing a solution, we should be taking into account the worst scenario.

As I mentioned above, "Unless otherwise you are very good at naming conventions and style of coding", it is always better to local view methods.

Anyway the developer would be the best person, to answer this.

Also is wd_comp_controller->registerViewXYZ(this_controller), a new method created by you in the component controller?

THanks,

Anand

Answers (0)