controller

cakephp url modification: remove action and add slug inflector

倖福魔咒の 提交于 2019-12-06 19:47:39
I'm trying to remove the action in the cakephp url and add a slug inflector, to be more clear this is my expected output: from this: example.com/posts/view/81/This is a test post to this: example.com/posts/This-is-a-test-post This is my current code: That gives me this output: example.com/posts/view/This is a test post Controller: public function view($title = null) { if (!$title) { throw new NotFoundException(__('Invalid post')); } $post = $this->Post->findByTitle($title); if (!$post) { throw new NotFoundException(__('Invalid post')); } $this->set('post', $post); } view.ctp: $this->Html->link

C++ sending Joystick directional input to program

让人想犯罪 __ 提交于 2019-12-06 19:24:26
I'm trying to spoof a PS3 controller and send analog stick directional input to a specific program, but i can't figure out how the INPUT.hi struct works. I can send keypresses over with INPUT keys; keys.type = INPUT_KEYBOARD; keys.ki.dwFlags = KEYEVENTF_SCANCODE; keys.ki.wScan = 0x11;//hex for 'w' key SendInput(1, &keys, sizeof(INPUT)); Sleep(60);//delay to ensure game doesnt drop keypress keys.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP; SendInput(1, &keys, sizeof(INPUT)); and i believe that sending over joystick commands would work similarly, something like INPUT analogSticks;

Two controllers different HTML pages using same factory in Angularjs, but array is not updating on one?

痞子三分冷 提交于 2019-12-06 17:04:22
问题 I am stuck with Angular. I am trying to update an array on two different HTML pages, but this does not work. I tested this with giving the array an initial value and both pages display the values properly. Only when updating nothing happens on one page. I have tried these two things, but no luck and no errors in the console: .controller("ctrl1", function ($scope, Sender) { $scope.Sender = Sender; $scope.paired = Sender.paired; }) .controller("ctrl2", function ($scope, Sender) { $scope.Sender

Pass variable to UI-bootstrap modal without using $scope

余生颓废 提交于 2019-12-06 15:54:36
Since I am a beginner using AngularJS the $scope approach to pass data between different controllers and (in my case) a modal drives me crazy. Due to that reason, I googled around the web and found an interesting blogpost about passing data to a UI-bootstrap modal without using $scope . I had a deeper look at this blogpost and the delivered plunk which works pretty nice and started to adopt this to my own needs. What I want to achieve is to open a modal delivering an text input in which the user is able to change the description of a given product. Since this would provide more than a minimal

Symfony2 reusable functions in controllers

喜欢而已 提交于 2019-12-06 15:50:37
After some time without knowing how to do this properly, and avoid duplicating code in several controllers, I searched and again to seek, but can not find a clear answer. One case in particular, need to calculate several statistics data completed of an entity. This calculation will use in 3 different controllers. In two of them, I'll show broken down into different layouts, and on the third, I will use this data to make a global calculation. business logic for each calculation, involves more than 100 lines of code, I would have to triple in the different controllers. A scheme could be:

Keep getting: Neither BindingResult nor plain target object for bean name 'index' available as request attribute

淺唱寂寞╮ 提交于 2019-12-06 15:22:52
I can't understand what I am doing wrong. I have a controller: @Controller @RequestMapping(value = "/index.htm") public class LoginController { @Autowired private AccountService accountService; @RequestMapping(method = RequestMethod.GET) public String showForm(Map model) { model.put("index", new LoginForm()); return "index"; } @ModelAttribute("index") public LoginForm getLoginForm() { return new LoginForm(); } @RequestMapping(method = RequestMethod.POST) public String processForm(LoginForm loginForm, BindingResult result, Map model) { if (result.hasErrors()) { HashMap<String, String> errors =

Using TempData dictionary prevents RedirectToAction from working

孤街醉人 提交于 2019-12-06 14:18:13
I want to add view model to TempData in order to pass it to another controller like this (referring to last 2 lines): [HttpPost("register")] public async Task<IActionResult> Register(RegisterViewModel rvm) { if (ModelState.IsValid) { var result = await _authManager.RegisterUserAsync(rvm.FullName, rvm.Email, rvm.Password); if (result.IsSuccessful) { return RedirectToAction("Login", "Home", new { message = result.Message }); } else { TempData["rvm"] = rvm; return RedirectToAction("Register", "Home"); } } TempData["rvm"] = rvm; return RedirectToAction("Register", "Home"); } The problem is that,

Method controller does not exist.

泪湿孤枕 提交于 2019-12-06 14:17:43
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 [BadMethodCallException] Method controller does not exist. Question, is this form of doing it Deprecation or why anyone spot

How to make two posts with different contents in GrailsIntegrationTesting

谁都会走 提交于 2019-12-06 13:21:55
I'm testing a controller, and I cannot make two posts with different contents. Follows an example, in which I execute a post to the cardController, with some data (post1, with json1). Then, I execute another post, with different data (post2 with json2). But I cannot make the second post succesfully, because I've seen (debuggin the application), that the json in the request, is json1 again, and not josn2. So, how can I make two different posts in the same test? void testSomething(){ def json1 = [number: "345678000000007", exp_month: 5, exp_year: 2012] as JSON def strJson1 = json1 as String

ASP.NET MVC Controller parameter processing

送分小仙女□ 提交于 2019-12-06 13:18:34
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 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 controller at all.) The action method would look something like this: protected override void OnActionExecuting