tags:

views:

76

answers:

2

Hi,

Am using a view file,controller and a helper. am accessing data value through webserver. Steps: the controller get value from webserver and set it in the view. the view uses the helper to display the data in some format. But my helper again calls the webserver method to get the inner values. Is it correct the helper accessing webservice method? Is it the correct way of programming in mvc?

Thanks,

A: 

I will tell you what is written in the Ruby on Rails book. I can not remember the title right now but...

Helpers are usualy used for view rendering not for server calls.

Home it helps.

xpepermint
+1  A: 

IMO, a webservice is just another datasource and should be accessed via the model. If it's me, I handle it by either creating a new model for the service call (if the service call is in support of an existing entity, it may make more sense to make the call in that entity's model itself). My controller calls the model method, sends the data to my view which, in turn, forwards that data on to the helper.

This maintains the MVC separation, but still allows the data you need to make it's way into the helper where you need it.

Rob Wilkerson
+1, this is the best way to do it in the spirit of MVC
dr Hannibal Lecter