controller

Magento event observer not working on some machines

自闭症网瘾萝莉.ら 提交于 2019-12-08 01:54:57
问题 I cannot seem to figure out why my event observer works from my machine (and another coworkers) but not from other machines in the office. For example, I have an observer that listens for the event: controller_action_postdispatch_adminhtml_process_reindexProcess My code detects the event and runs some code. When I run the re-index process, my code executes. When certain other machines here in the office run the re-index, either the event is not fired, or my observer isn't detecting it. Why

Method controller does not exist.

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-08 00:42:30
问题 So I have used this format again. In my routes.php I have Route::controller('datatables', 'HomeController', [ 'PaymentsData' => 'payments.data', 'getIndex' => 'datatables', ]); In my HomeController.php I have public function getIndex() { return view('payments.index'); } /** * Process datatables ajax request. * * @return \Illuminate\Http\JsonResponse */ public function Payments() { return Datatables::of(DB::table('customer'))->make(true); } Anytime I try php artisan I get

ASP.NET MVC Controller parameter processing

会有一股神秘感。 提交于 2019-12-07 23:14:05
问题 In my application I have a string parameter called "shop" that is required in all controllers, but it needs to be transformed using code like this: shop = shop.Replace("-", " ").ToLower(); How can I do this globally for all controllers without repeating this line in over and over? Thanks, Leo 回答1: Write a custom action filter, override OnActionExecuting() and apply the filter to all your controllers. (Or simply overriding OnActionExecuting() in your base controller, if you have a base

How to return a partial view in a controller in ASP.NET MVC3?

Deadly 提交于 2019-12-07 21:12:28
问题 I have a controller and one of its methods (actions) access my database of items. That method checks the item type. How do I show my partial view only if the item retrieved from my database is of a specific type? Controller Action example: public ActionResult CheckItem(Koko model) { var item = db.Items.Where(item => item.Number == model.Number).First(); if(item.Type=="EXPENSIVE") { //show partial view (enable my partial view in one of my Views) } } 回答1: You could return a PartialView action

How to test JavaFX (MVC) Controller Logic?

旧时模样 提交于 2019-12-07 17:43:35
问题 How do we properly write unit/integration tests for the JavaFX Controller logic? Assuming the Controller class I'm testing is named LoadController , and it's unit test class is LoadControllerTest , my confusion stems from: If the LoadControllerTest class instantiates a new LoadController object via LoadController loadController = new LoadController(); I can then inject values into the controller via (many) setters. This seems the only way short of using reflection (legacy code). If I don't

Architecting ASP.net MVC App to use repositories and services

蹲街弑〆低调 提交于 2019-12-07 16:28:44
问题 I recently started reading about ASP.net MVC and after getting excited about the concept, i started to migrate all my webform project to MVC but i am having a hard time keeping my controller skinny even after following all the good advices out there (or maybe i just don't get it ... ). The website i deal with has Articles, Videos, Quotes ... and each of these entities have categories, comments, images that can be associated with it. I am using Linq to sql for database operations and for each

Controller method #show getting called

ⅰ亾dé卋堺 提交于 2019-12-07 15:57:11
问题 I have a link on my #index view: <%= link_to 'Export Calendar (ICS)', { controller: :tickets, action: :ics_export, format: :ics }, class: "class-needed right" %> routes.rb that pertains to this: resources :tickets get 'tickets/calendar' => 'tickets#ics_export' post 'tickets' => 'tickets#index' patch 'tickets/:id/close' => 'tickets#close', as: 'close_ticket' post 'tickets/:id' => 'ticket_comments#create' My TicketsController that pertains: before_action :set_ticket, only: [:show, :edit,

Checking session exists or not- mvc3

蓝咒 提交于 2019-12-07 15:39:27
I was googling on Sessions and mvc3, and I found this link . To that question a marc-gravell answered The session only really exists during the processing of an action - I wouldn't expect it to be valid in the constructor of a controller. For example, the controller might (for all I know) be re-used between requests. I think that may not be the case by reading further on mvc requests and creation of controller, I found this : A Controller is created for every request by the ControllerFactory (which by default is the DefaultControllerFactory). So I think, Marc was incorrect and we can simply

How to update two entities/model elements from one jsp in Spring MVC?

泪湿孤枕 提交于 2019-12-07 14:07:12
问题 My requirement is to do a CREATE operation by providing the user with a form in a JSP with input fields from two entities (e.g. UserDetails and EmploymentDetails ) What is the most effective way to update two forms in a single jsp using a single submit? One approach I know of is to combine the two entities into a single wrapper-class and then send that object as Model. Is that the only solution? Kindly guide. 回答1: It's a common practice to put any number of objects in a wrapper class and use

mvc controller test with session attribute

偶尔善良 提交于 2019-12-07 12:21:14
问题 I'm trying to test a method with this signature: @Autowired HttpSession http_Session; @RequestMapping(method=RequestMethod.GET, value="/search/findByName") public @ResponseBody List<Map> search(@RequestParam(value="name", required=true) String name){ Integer user_id = http_Session.getAttribute("userinfo"); } userinfo is a class which contains informations about the user and set in session scope when the user logged in.but when I try the test : @RunWith(SpringJUnit4ClassRunner.class)