controller

Calling javascript function from controller codeigniter

和自甴很熟 提交于 2019-12-05 07:59:52
问题 I am developing site using codeigniter.I have a form which contains add button and textbox. once the user enters the data i have to check whether it exist in database,if yes generate a dynamic textbox in the page else alert user. I have written javascript to generate dynamic textbox. My question is how to check in database??? how to call controller from javascript or to call javascript function from controller??? 回答1: This is actually so much easier than you expect.. and you will start to use

How to get JSON data in an Odoo controller using type='json'?

跟風遠走 提交于 2019-12-05 07:45:52
A few days ago I did a similar question here: How to get JSON data in an Odoo controller? But now, I need to create a controller which receives only JSON data. So, I am doing the request from a Python console, this way: import requests import json url = 'http://localhost:8069/odoo/test' headers = {'Content-Type': 'application/json'} data = { 'name': 'Jane', 'email': 'jane.doe@gmail.com', } data_json = json.dumps(data) r = requests.post(url=url, data=data_json, headers=headers) I have created a controller which listens to http://localhost:8069/odoo/test , this way: import openerp.http as http

Spring MVC binding a List of nested Custom types to multiple JSP forms

≯℡__Kan透↙ 提交于 2019-12-05 06:43:13
The Case: I've an Organization Object. It has a list of Department Objects, and each Department has a list of Employee Objects. In JSP, I have a checkbox list that binds a check box to an employee object (deep down 2 hierarchies. That is Organization->Department->Employee). <input type="checkbox" name="adminDepartmentList[${status.index}].employeeList" value="${employee.firstName}"> <c:out value="${employee.firstName}" /><br> As you can see: adminDepartmentList[0].employeeList --> John adminDepartmentList[2].employeeList --> Rose The binding is good. After form is submitted, in the controller,

How to pass variable from controller to the view joomla mvc

喜你入骨 提交于 2019-12-05 05:49:53
How do I pass my variable from joomla sub-controller to the view according to this example class MYControllerControllerParser extends JController{ public function __construct($default = array()) { parent::__construct($default); } protected function _import($file, $type) { $layout = ''; switch ($type) { case 'importcsv': $contains_headers = false; $field_separator = JRequest::getVar('separator'); $field_separator = empty($field_separator) ? ',' : $field_separator; $field_enclosure = JRequest::getVar('enclosure');; $field_enclosure = empty($field_enclosure) ? '"' : $field_enclosure; //this

ASP.NET MVC: Returning large amounts of data from FileResult

血红的双手。 提交于 2019-12-05 05:36:28
I have a file browser application in MVC4 that allows you to download a selected file from a controller. Currently, the FileResult returns the Stream of the file, along with the other response headers. While this works fine for smaller files, files that are larger generate an OutOfMemoryException. What I'd like to do is transmit the file from the controller, without buffering in memory in a fashion similiar to HttpReponse.TransmitFile in WebForms. How can this be accomplished? You can disable the response buffer before you return the file result. Response.BufferOutput = false; return File

Get current action's path/url including query string? (Rails)

独自空忆成欢 提交于 2019-12-05 05:12:52
Simple question - how do I get the path or full URL of the current action INCLUDING the query string? I wish to save it to the session variable like so: def show @thingy = Thingy.find(params[:id]) session[:some_var] = current_url ... end At the moment I'm doing the following, but it seems a bit heavy-handed (especially the specifying of query string params individually): def show @thingy = Thingy.find(params[:id]) session[:some_var] = thingy_path(@thingy, :q1 => params[:q1], :q2 => params[:q2]) ... end request.url is probably what you are looking for. access params variable,it will give you

Rspec, Devise, Factory girl - how to sign in Factory user through Rspec controller test?

≡放荡痞女 提交于 2019-12-05 05:12:23
I have a Posts controller and I have just installed Devise to add some authentication quickly and easily. Before I installed Devise, I had created some tests for the 'new' action of my Posts controller. After installing Devise, my tests were failing until i added the config.include Devise::TestHelpers, :type => :controller line to my spec_helper.rb file. I also have the line before_filter :authenticate_user!, :except => [:show, :index] in my PostsController. Now when I run my tests, they all pass except these 2: it "should be successful" do get :new response.should be_success end it "should

Spring: controller inheritance using @Controller annotation

。_饼干妹妹 提交于 2019-12-05 04:57:24
I'd like to be able to create a base controller in my Spring app that, among other things, determines if a user is a registered user or not. This base controller, following the template design pattern, would contain an abstract protected method that controller subclasses would implement. The abstract method would have passed to it an instance of User, registered or otherwise. However, I have no idea how I would do this since it seems that by using controllers purely using the @Controller annotation each controller is free to define their request handling method however they like. Would

HttpContext.Current.User is null in ControllerBase(asp.net mvc)

一曲冷凌霜 提交于 2019-12-05 03:58:14
I have a ControllerBase class in an ASP.NET MVC Application. The other controllers inherit from ControllerBase . I want to access HttpContext.User.Identity.Name , but HttpContext is null . What's the matter? public ControllerBase() { var dataManager=new DataManager(); if (HttpContext.User.Identity.IsAuthenticated) // throws error { ViewData["assets"] = ud.BalanceFreeze + ud.Balance + ud.BalanceRealty; ViewData["onaccount"] = ud.Balance; ViewData["pending"] = ud.BalanceFreeze; ViewData["inrealty"] = ud.BalanceRealty; } Nik Try adding your code to this event in your ControllerBase: protected

Spring and several controllers matching a single path variable

让人想犯罪 __ 提交于 2019-12-05 03:48:39
问题 In a Spring application, I have a controller with the following annotation: @RequestMapping(value = "/{category}/", method = GET) I'd like to have other controllers matching a single pre-defined path variable, e.g. @RequestMapping(value = "/payment/", method = GET) I think it is doable since I see several websites implementing this kind of URLs. E.g. you may have several paths for the categories http ://www.mysite.com/computer/ http ://www.mysite.com/smartphone/ http ://www.mysite.com/printer