controller

MVC - do I need to use Controller in the View?

泄露秘密 提交于 2019-12-03 07:27:48
As I know in the standard implementation of the MVC we pass Controller and Model to the View But Im a little bit disagree with this idea. I dont want my view to know about both controller and model (oh no. maybe sometimes view needs model, but I'm sure that he can live without knowledge of controller) In my opinion Controller should manage View and Model, and Model doesn't need to know about controller and view; view doesnt need to know controller (I dont exclude model because some implementations of views need to know about model to listen to changes in the model). So my idea is that view

Status messages on the Spring MVC-based site (annotation controller)

谁说胖子不能爱 提交于 2019-12-03 06:42:07
问题 What is the best way to organize status messages ("Your data has been successfully saved/added/deleted") on the Spring MVC-based site using annotation controller? So, the issue is in the way of sending the message from POST-method in contoller. 回答1: As mentioned by muanis, since spring 3.1, the best approach would be to use RedirectAttributes. I added i18n to the sample given in the blog. So this would be a complete sample. @RequestMapping("/users") @Controller public class UsersController {

Upload Photo To MVC 4 Applications

帅比萌擦擦* 提交于 2019-12-03 06:25:13
问题 I'm trying to create a controller to upload photos in my MVC4 application. But I keep getting this error. The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or a non-white space character among the padding characters. PhotosController.cs public class PhotoController : Controller { public ActionResult Index() { using (var ctx = new BlogContext()) { return View(ctx.Photos.AsEnumerable()); } } public ActionResult Upload() { return

StructureMap controller factory and null controller instance in MVC

末鹿安然 提交于 2019-12-03 06:22:39
I'm still trying to figure things out with StructureMap and one of the issues i'm running into is my Controller Factory class blowing up when a null controller type is passed to it. This only happens when the application builds for the first time, after which every subsequent build works fine. Even when i shutdown Visual Studio and reopen the project (I'm not running this in IIS). It's almost like there is some sort of caching going on. This is what the controller class looks like: public class IocControllerFactory : DefaultControllerFactory { protected override IController

twitter bootstrap modal with ruby on rails

别等时光非礼了梦想. 提交于 2019-12-03 06:18:52
问题 I have run into a bit of a problem and a head scratcher, as I'm not sure whether what I want to do is even possible with RoR. A bit of background info: I have an app with several controllers... and would like to work with 2 of them for this modal example. The first is a users_controller and the other is a recommendations_controller. Here is what I'm trying to do: In the user index view I have a lists of posts. Each post has a recommend button. If a user clicks it he/she is sent to the

Extending the IndexController with a BaseController in Zend

风流意气都作罢 提交于 2019-12-03 06:10:38
I'm trying to extend my controllers with a global base controller as such: class BaseController extends Zend_Controller_Action { // common controller actions public function listAction() { // do stuff } } class IndexController extends BaseController { // index controller specific actions } class LoginController extends BaseController { // login controller specific actions } But I get this error: PHP Fatal error: Class 'BaseController' not found in /var/www/Zend/project/application/controllers/IndexController.php on line 3 Any ideas on how to get Zend to "see" this controller? markus Autoloader

How Do You Convert a Page-Based PHP Application to MVC?

佐手、 提交于 2019-12-03 06:00:57
问题 I've been struggling for some time now with exactly how to recode a page-based PHP application using an MVC framework. Just for background, I am having to move the app into MVC because my boss is making me. Anyway, I've sat down, and printed out the directory structure. I've then started trying to plan how I can convert these pages into controller/action pairs. Some things seem very straight forward. For example, I had a couple pages devoted to add/edit/delete of a user. That's very easy to

When do @SessionAttributes in SpringMVC get removed? (With code sample)

て烟熏妆下的殇ゞ 提交于 2019-12-03 05:46:49
Under what exact circumstances do @SessionAttributes get cleared? I've discovered some confusing behaviour when trying to use two models in a page. When I do a GET followed by a POST using this controller... @Controller @RequestMapping("/myPage*") @SessionAttributes(value = {"object1", "object2"}) public class MyController { @RequestMapping(method = RequestMethod.GET) public String get(Model model) { model.addAttribute("object1", new Object1()); model.addAttribute("object2", new Object2()); return "myPage"; } @RequestMapping(method = RequestMethod.POST) public String post(@ModelAttribute(value

ASP.NET MVC - Current Action from controller code?

只谈情不闲聊 提交于 2019-12-03 05:44:25
This is very similar to another recent question: How can I return the current action in an ASP.NET MVC view? However, I want to get the name of the current action from within controller code. So within the code of a function that's being called by an Action, I want to get a string of the name of the current Action. Is this possible? You can access the route data from within your controller class like this: var actionName = ControllerContext.RouteData.GetRequiredString("action"); Or, if "action" isn't a required part of your route, you can just index into the route data as per usual. The only

Why does Rails create a controller for every request?

落爺英雄遲暮 提交于 2019-12-03 05:43:59
问题 From my previous question I understood that Rails creates a controller instance for every request. My question is, because this subject is related to the design of the project I'm working on: Why does Rails creates a new instance of class SomeController < ApplicationController; end to process every incoming request? Why not just create singleton object and forward requests to this one? This seems more efficient as we won't waste resources on allocating and cleaning objects for request? 回答1: