Does MVC normally have a separate Controller for every View? - model-view-controller

I'm just browsing MVC examples so far, and I think I'm getting a handle on it. For my project - an embedded system on ARM9, no Windows/ASP at all - we are considering doing all the UI as MVC. Does MVC also require a strict Tree of all UI Views (one root?)

No, one controller may have different views for different actions.

You can split the controller into a front controller and several actions.
As reference see The MVC Pattern as implemented into Symfony framework.

If your views are parts of a full page you might also use the same view from different controllers. Ie header and footer.

A controller can have many views and partial views. If you take a look at some simple ASP .NET MVC tutorials: http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/intro-to-aspnet-mvc-4 you'll learn how this can be done easily.

Related

Create custom controls in asp mvc 3

I have to create custom controls in ASP.NET MVC 3. Controls like customized buttons which I will put in DLL and reuse in any project.
Do you know a good way or maybe you can give me a good tutorial to do this.
Thanks.
You can't, WebControls are for Web Forms. In asp.net mvc anything view related(html, javascript, css) is decoupled from the controller. The best you can do is to have helpers which are simply extension methods. But something similar to the webcontrols is specific to web forms only.
This post and this should give you an idea
You would need to use Partial Views to re-use code.
http://rachelappel.com/razor/partial-views-in-asp-net-mvc-3-w-the-razor-view-engine/

MVC Source Files

I'm researching a basic, stand-alone UI app that I want to be 'MVC compliant'.
My question is, what is the typical correlation of the three layers to source code files?
In other words: should I expect to see separate fooView, fooModel and fooController files, or are some functions (eg. Controller) typically specified declaratively and/or handled by a framework?
I realize there are a million MVC frameworks and that the answer probably varies, just looking for a general concept. Cheers and thanks.
Start with the server-side language that you have available and narrow down your MVC framework from there. I would stick with a framework that fits your programming style and needs. Yes, you should have three unique layers (models, views, and controllers) and they should not mix. I.e., in ASP.NET MVC projects you would find a controller, model, and view folder.

What new features would you like to see in Asp.net MVC 3?

Asp.net MVC 3 preview 1 was released at the end of last month. Are there any new features you are excited about or any features you would like to see before it is fully released?
Full support for Controllers with Generic Parameters
public GenericController<SomeType> : Controller
Generic controllers are quite possibly the greatest MVC timesaver if your doing a lot or business CRUD. There are so many similarities between the Add methods of almost every MVC project that it makes sense to abstract these operations out in a Controller that fits all scenarios.
Right now its a little hacky to create a generic controller. The MVC engine always gets the name wrong (GenericCo vs. Generic) and without full support plugin and libraries that interact with controllers just fall over when they encounter a generic one.
Make Dropdowns easier to work with
As a professional MVC tag watcher I've noticed that working with dropdowns is one of the most repeated questions on SO. The amount of Dropdown questions is a strong indication that something should be done to make it easier or less ... complex?
make checkbox list easy to work with
add T4MVC to the official release
add official helpers for OData
support one javascript library either MS Ajax or jQuery(preferably)
I wish they can add something to help developer to migrate their previous ASP.NET WebForms application.

Zend framework techniques

I am trying to migrate to zend framework. Should each webpage be a Controller or an action.
What is the advantage of having multiple actions. Can they talk to each other? and whats the best use of Action helpers and View helpers.
Please guide me on how to start on the framework.. thanks
You can use a new controller for each page or define multiple actions on the same controller to render your pages. I choose to use defferent action from the same controller to display variuos pages. Using multiple action on the same controller allows you to put some code in che constructor of the controller that is executed for each action. For example i have a controller for all the pulic pages of a website and a new controller for those pages that are reserved to registered users. In the constructor for the controller dedicated to registered user i do the check for authentication.
You should check that page about MVC applications, It's not precisely related to Zend. But you seems to be asking what a MVC Design Pattern is.
You got to create a controller for each of your site's pages. If any page interacts with db, you should also create model for that page. Also you should create view for each of your page.
If you have no idea about MVC, you can read this:
MVC
Those links are from Zend Framework manual.
Do not afraid and click - read the Introduction chapters - you will have all answers. ;-)
View helpers
Action helpers
Action Controllers
First get a sound understand of MVC Framework:
Understanding MVC Architecture from its Origin (part I)
http://learnnewprogramming.com/blog/understanding-mvc-architecture/

MVC Pattern in cakephp

Could someone explain me about MVC pattern? How does it help cakephp framework?
MVC stands for Model, View, Controller.
Model = Data (Database tables)
View = HTML, CSS, JavaScript, etc
Controller = Main logic, a contract between Model & View.
In simple and graspable terms,
MVC allows you to develop your applications in a way that your business data and presentation data are separated. With this, a developer and designer can work independently on a MVC app without their work clashing. MVC makes your app avail OOP too.
Have a look at the respective section in the cookbook.

Resources