mvc

What design pattern? I need two modes in my app, edit and view.

If I need two modes in my application what design pattern would I use so I can prevent ugly conditional code? App is currently MVC, but I don't want conditional code in my controllers and don't want two controllers for each view unless I have to. Any suggestions? ...

How to pass data from javascript to c# (asp.net mvc)

how i return a value from javascript function to a c# variable (in controller) and also i have a multicolum dropdown box in a form , eg book details , when the user makes the selection the book name is set in the dropdown , but when submit is hit i want the code book to be returned(this value is returned by my javascript) for billing p...

Mocking a DataServiceQuery<TElement>

How can I mock a DataServiceQuery for unit testing purpose? Long Details follow: Imagine an ASP.NET MVC application, where the controller talks to an ADO.NET DataService that encapsulates the storage of our models (for example sake we'll be reading a list of Customers). With a reference to the service, we get a generated class inheritin...

How to show conditional data in views in MVC frameworks?

How do people generally handle conditional statements in MVC frameworks For some of my pages (made under Kohana) I want the user to have more options depending on whether they are logged in or not, and whether the profile is their own profile for example. From your own experience, do you create separate views, empty variables, do the l...

Component controller in Spring-MVC

I am designing a web application that requires loading multiple components on a single page. (In terms of page layout is similar to Google reader) I like to keep these components separate from each other (for reasons such as reusability). For example, I have a left panel that let's user navigate among multiple feeds that he's subscribed...

ActionFilterAttribute - apply to actions of a specific controller type

I'm using an ActionFilterAttribute to do custom authentication logic. The Attribute will only be used on a derived Controller class that contains my authentication logic. Here's my Controller, derived from my custom controller class, and a sample attribute: public class MyController : CustomControllerBase { [CustomAuthorize(UserTy...

Using MVC and fluent Nhibernate, how do I validate unique fields on my ViewModel before I bind them to my Domain Object and Save them?

I have a website where I allow users to create new Part records. I'm trying to figure out the best way to validate specific fields for uniqueness. I want to make sure that somebody doesn't try to add a Part with PartNumber 1234 if that PartNumber already exists on a different Part. The Web Application is using Asp.net MVC with fluen...

I need to re route action based on some criteria

If a user is logged in and the ChangePasswordRequired flag is set, i need to disregard the current action and redirect them to the ChangePassword action. In other words, I do not want the user to be able to do anything until he or she changes his or her password. Which method should my base controller override and how should I handle t...

CakePHP RequestHandler: setContent/renderAs/respondAs .. what?

Can someone please explain these functions: RequestHandlerComponent::renderAs() RequestHandlerComponent::respondAs() RequestHandlerComponent::setContent() It feels slightly redundant to have all three of them (as public methods anyway). If I want to respond to a request with a PDF file, does that mean I'd have to call all three fun...

How is coordination of child views best handled in MVP?

I am attempting to use MVP in WinForms and am confused on how to best handle coordination among child views. For example, I have a parent view that has two child views. Events on one child view need to cause an action to be taken by the second child view. Should the parent view control this directly? It seems like I am bypassing the M...

Dynamically loading view controls in a view page with asp.net mvc. Possible?

I'm trying find a way to do something with MVC that I was able to do with WebForms. I have a set of steps a user needs to go through to fill in data. In a previous case it was registering animals on an 'classifieds' site that was designed in webforms. For simplicity lets say it has 3 pages. Page 1 asks them what type of animal in a drop...

controller sample code in php mvc framework and also support URL Routing

Please help me in coding for controller and support for URL Routing for PHP MVC framework. ...

Web site creation in MVC, and with out any frameworks, but in Simple PHP, what would be the structure ?

HI All, I want to create a web site in MVC architecture, with out using any frameworks. What would be the Files/Folder structure (Module/Views/Models). EDIT: I know the Zend, CakePHP. but my Question is how can we structure in Simple PHP. I dont want to use any of the frameworks, because i need the maximum performance/speed. I heard t...

Strongly typed views

is it possible to pass derived types where base types are expected to strongly typed views? I.e Products/List News/List where "list" view Inherits System.Web.Mvc.ViewPage<Model<BaseList>> controller renders view i.e View("List", ProductsList) edited return View("List", new Model<ProductsList>()); Model<T> where T : IMyList Pr...

Where can i get good sample codes and references in PHP for MVC Framework with URL Routing?

I am trying to implement a application which i need to follow mvc framework. But I need to gather some ideas in that. Please give me some suggestions and references which includes some sample codes in PHP with URL routing. ...

ASP.NET MVC Strongly Typed View for class that has a collection of objects

Consider this scenario: class Book { int id; List<Category> categories; } class Category { int id; string name; } I have a strongly typed view for the class Book. When the librarian wants to edit the details of any Book, I want to display checkboxes with all possible categories. In case Book.categories contains a cate...

Clean way for conditionally rendering HTML in view?

Is there a cleaner way to do this in a JSP/Struts1 setup ? <% if (SessionConfig.isAdminMode() ) { %> ... some HTML here ... <% } %> EDIT: In admin mode I would like to have access to additional parameters from a form element, e.g. from the form element: input type="text" value="Test user" name="Owner" EDIT 2: Actually, my probl...

ASP.NET MVC - Determine Client's Computer Name

I am building an intranet site that will display different lists based on the computer name because different computers are in different areas, is there a way (within a controller or model) to determine the client's computer name? I have tried system.environment.machinename but that only returns the name of the server, any other ideas? ...

MVC Catch All route not working

My first route: // Should work for /Admin, /Admin/Index, /Admin/listArticles routes.MapRoute( "Admin", // Route name "Admin/{action}", // URL with parameters new { controller = "Admin", action = "Index" } // Parameter defaults ); is not re...

Universal template/config syntax

I have a number of applications written in different languages (Java, JavaScript, PHP, etc.). Their view/presentation layers display things in various formats: HTML, plain text, etc. I want to display some textual/numeric data in roughly the same way in each application. Of course, the result would be slightly different depending on the...