controller

Spring MVC controller return HTML

允我心安 提交于 2019-12-03 05:38:23
I am having an issue trying when trying to return HTML to my Spring MVC controller. It looks like this: @RequestMapping(value = QUESTION_GROUP_CREATE_URL, method = RequestMethod.POST) public @ResponseBody String createQuestionGroup(@RequestBody JsonQuestionGroup questionGroup, HttpServletResponse response) { // questionGroup - this comes OK. response.setContentType("text/html"); response.setCharacterEncoding("UTF-8"); return "<div></div>"; } My Spring config: <bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean"> <property name=

How to call ApplicationController methods from ApplicationHelper

浪尽此生 提交于 2019-12-03 05:23:52
问题 I want to provide csv links in a view and I placed the csv generating code in ApplicationHelper . However I'm getting this error: undefined method `send_data' for #<#<Class:0x0000010151c708>:0x0000010151a070> referencing this: send_data content, :type => "text/plain", :filename => filename, :disposition => 'attachment' If I place the csv code in a controller it works fine. I was hoping to use the helper to avoid having to define routes for every controller I want to provide csv options for (I

Breadcrumbs in Ruby on Rails

一个人想着一个人 提交于 2019-12-03 05:05:57
问题 I'm slightly insecure about my breadcrumb solution. Names and links are defined in each controller action: <a href="http://localhost:3000/">Home</a> <% if defined? @l1_link %> > <a href="<%= @l1_link%>"><%= @l1_name %></a> <% if defined? @l2_link %> > <a href="<%= @l2_link%>"><%= @l2_name %></a> <% end %> <% end %> This way I can use: @l1_link = user_path() Question: As I am not that smart - could this kind of system lead to desaster somewhere down the road? Is this (grossly) inefficient? 回答1

loading a view after an ajax call, CodeIgniter

折月煮酒 提交于 2019-12-03 04:43:21
I have an ajax call from javascript to a method in a controller, the method in the controller should be loading a view(like, show a new page on the screen), Although everything seems ok, the new view doesn't seem to load on the screen. I cannot use header or windows.location because, i am passing an array variable, containing data to be used in the view. The page is visible under the Network tab (preview sub tab, while selecting the ajax) of the Chrome debugging console. But the main screen stays as it is. If somebody has faced a similar issue, or has a solution, please help me. Thanks!!

ExecuteCore() in base class not fired in MVC 4 beta

核能气质少年 提交于 2019-12-03 04:40:58
问题 I have a base controller class: And all my other controller inherits this BaseClass like this All this works great in MVC3 (test again today, it really works) but it seems that the ExecuteCore in BaseController is not fired any more in MVC 4 beta. Any idea? Or Anything huge has changed under the hood? Thanks very much. public class BaseController : Controller { private string _myData; public string MyData { get { return _myData; } } protected override void ExecuteCore() { _myData = "I am

AngularJS directives attributes access from the controller

扶醉桌前 提交于 2019-12-03 04:08:35
问题 I am trying to access the attributes of a directive in the controller function. However, by the time I access it, it is undefined. I noticed that if I do a simple timer it works. Is there a way to execute code only after the directive and it's scopes are ready and set to be used? I made a fiddle with it. Make sure your console is open. http://jsfiddle.net/paulocoelho/uKA2L/1/ Here is the code I am using in the fiddle: <div ng-app="testApp" > <testcomponent text="hello!"></testcomponent> </div

VHDL microprocessor/microcontroller

点点圈 提交于 2019-12-03 04:07:35
I'm learning to code on Xilinx (VHDL). Next, I want to make a simple microprocessor/microcontroller and on the way learn a little about slice components. So my goal is try to code an 8 bits microprocessor using an AMD 2901 (4 bits-slice). (I already have the code of the 2901 and all its information about its input and output signals.) I know the first step would be make the architecture of the microprocessor so I ended up with something like this (I understand that the bandwidth of the bus will be very different for what I'm looking for). http://www.cs.binghamton.edu/~reckert/wk15fig1.JPG

How to inject a controller into a directive when unit-testing

南楼画角 提交于 2019-12-03 03:57:08
I want to test an AngularJS directive declared like this app.directive('myCustomer', function() { return { template: 'cust.html' controller: 'customerController' }; }); In the test I would like to inject (or override) the controller, so that I can test just the other parts of the directive (e.g. the template). The customerController can of course be tested separately. This way I get a clean separation of tests. I have tried overriding the controller by setting the controller property in the test. I have tried injecting the customController using $provide . I have tried setting ng-controller on

Get checkbox values in controller mvc 4

家住魔仙堡 提交于 2019-12-03 03:51:18
I am trying to retrieve the checked checkbox value from a checkbox list without any success , below is the code which i have tried: Model [DisplayName("Gender")] public IList<SelectListItem> Gender { get; set; } Controller public ActionResult Index() { AssociateFormViewModel objStudentModel = new AssociateFormViewModel(); List<SelectListItem> genderNames = new List<SelectListItem>(); genderNames.Add(new SelectListItem { Text = "Male", Value = "1" }); genderNames.Add(new SelectListItem { Text = "Female", Value = "2" }); genderNames.Add(new SelectListItem { Text = "Prefer not to say", Value = "3

Returning from rails controller

こ雲淡風輕ζ 提交于 2019-12-03 03:41:11
Here's a beginner rails question... After I do: format.xml { head: ok} How do I return from the controller endpoint without showing the view? If I drop off the end of the function at this point, I get what I expect, but if I call 'return', I end up in the view (or in my case in a missing view template). I can code up lots of if/else etc., but it would be nice to early out from the function without ending up in a view template. I've searched around and can't figure out what the obvious answer is to this; it must be straightforward... Lee Hambley You can use " render :nothing => true, :status =>