dole doug
dole doug

Reputation: 36038

MVC related question

let's consider a web application built using MVC concept. If my application generates some chart images dynamically based on the user input and a database I wish to know which component the image generation process will belong to: controller or view?

It's controllers job to generate the image and the view component to display it?

Upvotes: 2

Views: 170

Answers (4)

PHeiberg
PHeiberg

Reputation: 29801

The controller is responsible for coordinating the generation of the image. The image can be generated by an HttpHandler, some other component capable of generating the stream or static resource that should be returned.

As an addition to the other answers, here's an example.

Upvotes: 1

Myles
Myles

Reputation: 21500

You are correct, a controller should generate the image and the view should display it. This would most likely be handled by a setting the "src" attribute of an image to a controller/dispatch that streams binary data, but it's up to you how exactly you implement that.

Upvotes: 1

Hannoun Yassir
Hannoun Yassir

Reputation: 21182

yes, but i would make a class that generate the chart which would be invoked by the controller

Upvotes: 2

jldupont
jldupont

Reputation: 96716

in short, yes you are correct.

Upvotes: 1

Related Questions