controller

Spring MockMVC inject mockHttpServletRequest when not in method signature

ぐ巨炮叔叔 提交于 2019-12-04 16:42:05
问题 Given I have inherited some Spring MVC controller code with signature @RequestMapping(value = "/upload", method = RequestMethod.POST) public ModelAndView upload(HttpServletRequest request, HttpServletResponse response) { String remoteAddress = request.getRemotedAddr(); auditService.logAddress(remoteAddress); // do work... return mav; } and I have a Spring MockMvc test that performs the test public void someTest() { mockMvc().perform(fileUpload("/upload").file(FileFactory.stringContent("myFile

How do i override Mage_Core_Controller_Request_Http

扶醉桌前 提交于 2019-12-04 16:31:03
I have made some changes to Mage_Core_Controller_Request_Http but in the file distributed by with magento. This is not the best way, i know, but i have not been able to work out how to override a file in the Controller directory. I can find out how to override files in the controllers directory. Can anyone tell me how i can override Mage_Core_Controller_Request_Http in my own extension. thanks If you don't want to revert to the include path hack, you can also use reflection to set your own request class on the Mage_Core_Model_App model. You can use an observer for controller_front_init_before

AngularJS DRY controller structure

泪湿孤枕 提交于 2019-12-04 16:22:34
The code below represents a situation where the same code pattern repeats in every controller which handles data from the server. After a long research and irc talk at #angularjs I still cannot figure how to abstract that code, inline comments explain the situations: myApp.controller("TodoCtrl", function($scope, Restangular, CalendarService, $filter){ var all_todos = []; $scope.todos = []; Restangular.all("vtodo/").getList().then(function(data){ all_todos = data; $scope.todos = $filter("calendaractive")(all_todos); }); //I can see myself repeating this line in every //controller dealing with

How to get entity manager for Doctrine entity with Symfony 2.1 from inside controller

Deadly 提交于 2019-12-04 16:13:33
问题 How can I get an entity manager from inside a controller with latest Symfony and Doctrine? The way described in "The Book" flagged as deprecated now. What is a modern (proper) way to do this? public function someAction() { // getEntityManager() from Doctrine\Bundle\DoctrineBundle\Registry is deprecated $entityManager = $this->getDoctrine()->getEntityManager(); ... } 回答1: Use $this->getDoctrine()->getManager() instead. Actually, it's best not to make controllers aware of the persistence layer

When a javaFX's controller is not enough to display content, it will display “…” at the end?

心不动则不痛 提交于 2019-12-04 16:09:00
My question is that can I catch the event of display "..." ? ※ I mean does javaFX have a API to judge if the end of the content is replaced with "..."? In fact, the reason for my question is that now our testers want us to set a TIP on one controller(like Label) if it is only not enough to display. If the content is enough to display in the controller, we don't need to add a TIP then. There's no easy way of telling if a text has been clipped. This clipping is done on Labeled objects, and in the implementation of LabeledSkinBase, we can see that all the logic for clipping is delegated to

Limit access by Controller or by Model?

南笙酒味 提交于 2019-12-04 15:49:55
I'm just starting to sketch up the base of a web-based system, and I would like the admin to have the possibility to limit access either by Controller or by Model. My problem is, I can't decide which one (or both?) of them I should go with. Any ideas? Pros/Cons? First I was leaning towards doing it in the Controllers, seeing as they "control" the flow of the system. But then, thinking that the access should probably be limited by the data it accesses, not the logical part of the system, I felt like I really should go with the Model. Now I just can't decide.. I've been bouncing back and forth

Route to redirect to a controller + an action by default on CodeIgniter?

偶尔善良 提交于 2019-12-04 15:05:42
I'm currently working on a project with Codeigniter. I have one controller called Cat class Cat extends CI_Controller { function __construct(){ parent::__construct(); } function index($action){ // code here } } and a route (in routes.php) $route['cats/:any'] = 'cat/index/$1'; And that works if I use this URL for example: http://www.mywebsite.com/cats/display Nevertheless, if the user changes the URL to http://www.mywebsite.com/cats/ it doesn't work anymore. Codeigniter writes: 404 Page Not Found - The page you requested was not found. So my goal is to redirect him to http://www.mywebsite.com

Passing multiple result sets to a view from a controller in ASP.NET MVC?

浪尽此生 提交于 2019-12-04 14:51:37
问题 So I have a controller set up as follows: using NonStockSystem.Models; namespace NonStockSystem.Controllers { [Authorize(Users = "DOMAIN\\rburke")] public class AdminController : Controller { private NonStockSystemDataContext db = new NonStockSystemDataContext(); public ActionResult Index() { var enumProducts = from p in db.Products select p; ViewData["Title"] = "Administration"; return View(enumProducts.ToList()); } } } The Index view on the Admin controller just lists the products in the

MVC How to keep a model skinny [closed]

你离开我真会死。 提交于 2019-12-04 14:47:57
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . After watching this video, I am wondering if I am using my controllers wrong. What exactly should a controller contain? For my blog, I have a post controller which has methods: create show list loadPost like dislike Whereas my post model only has a few access rules, validation rules and relation information. Are

Passing page URL parameter to controller in Laravel 5.2

女生的网名这么多〃 提交于 2019-12-04 13:50:22
In my application I have a page it called index.blade , with route /index . In its URL, it has some get parameter like ?order and ?type . I want to pass these $_get parameter to my route controller action, query from DB and pass its result data to the index page. What should I do? Achraf Khouadja If you want to access the data sent from get or post request use public function store(Request $request) { $order = $request->input('order'); $type = $request->input('type'); return view('whatever')->with('order', $order)->with('type', $type); } you can also use wildcards. Exemple link website.dev