controller

Codeigniter extending controller, controller not found

给你一囗甜甜゛ 提交于 2019-12-30 02:03:29
问题 In Codeigniter 2.1.2 I want to create base controller and then extends from this controller. It does not work and I have no idea why and I'm pretty desperate now. In \application\core\MY_Base_Controller.php I have this: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class MY_Base_Controller extends CI_Controller { function __construct() { parent::__construct(); ... In \application\controllers\Home.php I have this: <?php if ( ! defined('BASEPATH')) exit('No direct

Soft Delete all records from a table in laravel 5

青春壹個敷衍的年華 提交于 2019-12-29 10:00:07
问题 Is there any way to soft delete all the existing rows in a table? I have tried ( Prospect::delete(); ) it deleted all the rows permanently, But it doesn't work in soft deleting. 回答1: If you are using Laravel framework older than 4.2, then you can set the soft delete in your model as, class ModelName extends Eloquent { protected $table = 'table_name'; protected $softDelete = true; } If you are using Laravel framework 4.2, then you can set the soft delete in your model as, use Illuminate

How to Change ASP.NET MVC Controller Name in URL?

故事扮演 提交于 2019-12-29 06:37:08
问题 If we have "example_name" we can change it in url using [ActionName("")] So, i want to do this for controller name. I can do this: ControllerName > example_nameController > in URL: "/example_controller" I would like to change controller name like this in URL: "/example-conroller" 回答1: You need to use Attribute Routing, a feature introduced in MVC 5. Based on your example you should edit your controller as follows: [RoutePrefix("example-name")] public class example_nameController : Controller

MediaController with MediaPlayer

给你一囗甜甜゛ 提交于 2019-12-29 02:48:30
问题 I want media controls such as play/pause for streaming audio that I am playing in my app. I am using MediaPlayer to stream and play the audio. Can someone provide a code snippet on how to use MediaController with MediaPlayer? Thanks Chris 回答1: It's quite simple to add media controller in a media player. Make your activity implement MediaPlayerControl and add unimplemented methods. Code is as below: I am using code from Api demos from here http://developer.android.com/resources/samples

AngularJS, ui.router, load template and controller based on user role

强颜欢笑 提交于 2019-12-29 02:43:24
问题 I have developed a Single Page App that uses a REST api. Users are required to login to access the application. When a user logs in they are redirected to /dashboard. On this URL / route, I would like to load a different template and controller based on the role of the user (e.g. normal user or admin user). I have looked at https://github.com/angular-ui/ui-router/wiki under the templates section but none of the options support what I am trying to achieve. By using templateUrl and function

Rails 4 - Nested form with accepts_nested_attributes_for controller setup?

荒凉一梦 提交于 2019-12-28 18:39:52
问题 I'm trying to make a nested form with form_for and fields_for . After much research and in-success, not working on my project anymore. I'm just trying to recreate a railscast to see what have I done wrong. I'm trying to re-create the example found at http://railscasts.com/episodes/196-nested-model-form-part-1 which shouldn't be that hard since the code is there, but I can't manage to create questions from the survey. Here is my code until now: rails new surveysays rails g scaffold survey name

Rails: Prevent duplicate inserts due to pressing back button and save again

[亡魂溺海] 提交于 2019-12-28 13:38:12
问题 Think about a simple Rails scaffold application with a "new" action containing a form to add records to a database with a "save" button. After the "create" action the controller redirects to the "show" action, where the user can use the "edit" link to edit the just inserted record. So far, so simple. But if the user instead uses the browser's back button after creating a record to get back to the "new" action, the browser shows the form with the values the user just has entered. Now he

ASP.NET mvc 4 controller parameter always null when sending json to controller, why?

冷暖自知 提交于 2019-12-28 12:07:01
问题 There are some similar posts already here, and tried every solution suggested, and still does not work... I can not get value inside controller, it is always null. Below is the code. Am I missing something? Client side javascript function getChart() { JSONString3 = { HAxis : [{ Name : "monday" }] }; jQuery.ajaxSettings.traditional = true; $.ajax({ url: "@Url.Action("getChart","SBM")", type: 'POST', contentType: 'json', dataType: 'html', data: JSONString3, success: function (data) { var

How to access plain json body in Spring rest controller?

孤街浪徒 提交于 2019-12-28 11:57:58
问题 Having the following code: @RequestMapping(value = "/greeting", method = POST, consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) @ResponseBody public String greetingJson(@RequestBody String json) { System.out.println("json = " + json); // TODO json is null... how to retrieve plain json body? return "Hello World!"; } The String json argument is always null despite json being sent in the body. Note that I don't want automatic type conversion, I just want the plain json

ASP.NET MVC download image rather than display in browser

大城市里の小女人 提交于 2019-12-28 11:44:42
问题 Rather than displaying a PNG in the browser window, I'd like the action result to trigger the file download dialogue box (you know the open, save as, etc). I can get this to work with the code below using an unknown content type, but the user then has to type in .png at the end of the file name. How can I accomplish this behavior without forcing the user to type in the file extension? public ActionResult DownloadAdTemplate(string pathCode) { var imgPath = Server.MapPath(service