controller

How to use @RequestParam(value=“foo”) Map<MyEnum, String> in Spring Controller?

爷,独闯天下 提交于 2019-12-11 02:16:56
问题 I want to use some Map<MyEnum, String> as @RequestParam in my Spring Controller. For now I did the following: public enum MyEnum { TESTA("TESTA"), TESTB("TESTB"); String tag; // constructor MyEnum(String tag) and toString() method omitted } @RequestMapping(value = "", method = RequestMethod.POST) public void x(@RequestParam Map<MyEnum, String> test) { System.out.println(test); if(test != null) { System.out.println(test.size()); for(Entry<MyEnum, String> e : test.entrySet()) { System.out

Hide Codeigniter controller name from URL with same routes

冷暖自知 提交于 2019-12-11 02:06:17
问题 i'm just getting started at codeigniter, i want to hide controller name from URL with same routes setup. i have 3 controllers which are students, staff, teachers having same function called home, this won't work obviously $route['home'] = 'students/home'; $route['home'] = 'staff/home'; is there any way to accomplish this? i have session data using codeigniter session class containing user type so i tried something like this session_start() $route['home'] = $_SESSION['user_type'].'/home'; but

How do I test a controller with rspec-rails?

喜欢而已 提交于 2019-12-11 01:59:27
问题 I want to test that my edit recipe page renders using rspec, though it doesn’t route to recipes/edit it routes to recipes/id/edit (id being replaced with a number) my current test looks like this describe "Show Edit Recipe Page" do it "should display edit recipe page" do get :edit response.should be_success response.should render_template(:edit) end end how can i test this page correctly, at the moment my tests are failing 回答1: Problem Your example doesn't include the code needed to actually

JavaFX controller to controller - access to UI Controls

你。 提交于 2019-12-11 01:30:27
问题 After research on my MVC javaFX - Problem without any solution for more than 2 days, I decided now to post it: I've one application Window divided by different SplitPanes and each of this Panes has its own .fxml-form controlled by its own controller. My Question is: How is it possible to get access to external UI-Controlls? For Example: Clicking on a TableView-row should effect to fill Textfields in an other Form. My current (not working) Solution is as follows: 1st Controller: Providing an

Ember.js Controller Does not work

泪湿孤枕 提交于 2019-12-11 01:29:03
问题 I can't access to my array controller variables. I have this simple application for example: App.js App = Ember.Application.create(); App.ApplicationAdapter = DS.FixtureAdapter.extend(); App.Router.map(function() { this.route('hello'); }); App.IndexRoute = Ember.Route.extend({ redirect: function() { this.transitionTo('hello'); } }); App.HelloController = Ember.ArrayController.extend({ name: 'tom' }); App.HelloRoute = Ember.Route.extend({ model: function() { return this.store.find('hello'); }

Module route in Rails with form_for(@object)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 00:58:41
问题 I have namespaced Controller Entities::Customers class Entities::CustomersController < ApplicationController ... end and namespaced ActiveRecord model: class Entities::Customer < Entities::User end in my routes.rb file i have: resources :customers, module: :entities The module :entities is there because i don't want to have routes such as: /entities/customers but only: /customers . The problem starts when i'm rendering my form: <%= simple_form_for(@customer) do |f| %> <%= f.input :email %> <%

MVC 4 return JSON as ActionResult

早过忘川 提交于 2019-12-11 00:42:55
问题 i'm trying to get my apicontroller to work. But somehow i cannot return Json() . Here's the error message from the compiler: Error CS0029 Cannot implicitly convert type 'System.Web.Http.Results.JsonResult<>' to 'System.Web.Mvc.JsonResult' Opten.Polyglott.Web D:\Development\git\Opten.Polyglott\src\Opten.Polyglott.Web\Controllers\NewsletterApiController.cs I cannot explain why it cannot convert the Json() to the ActionResult even the Json() inherits ActionResult . Here's my controller: using

Swift generic type property and method

萝らか妹 提交于 2019-12-11 00:40:20
问题 How do I store generic type in property and then use that type property to pass in method? I have factory whose method receives view controllers type but returns instance of that view controller (container takes care of that). public protocol ViewControllerFactoryProtocol { func getViewController<T: UIViewController>(type: T.Type) -> UIViewController } public class ViewControllerFactory: ViewControllerFactoryProtocol { private let container: Container public init(container: Container) { self

Spring: How do I set the pattern of a @DateTimeFormat from a properties file?

China☆狼群 提交于 2019-12-11 00:13:23
问题 I'm using Spring 3.1.1.RELEASE. I have a model that I submit to one of my controllers. In it, is the following field @DateTimeFormat(pattern = "#{appProps['class.date.format']}") private java.util.Date startDate; However, the above doesn't work (the EL isn't being interpreted), in as far as every time I submit my form, I get an error. If I use the following @DateTimeFormat(pattern="yyyy-MM-dd") private java.util.Date startDate; everything works fine. But ideally, I'd like to drive the pattern

grails controllers render errors

梦想与她 提交于 2019-12-10 23:35:32
问题 class Person { String name Integer age String street String email } class PersonController { def save = { def personInstance = new Person(params) personInstance.save(flush:true) } } main.gsp <g:form controller="person" action="save"> <g:textField name="name" /> <g:textField name="age" /> <g:textField name="street" /> <g:textField name="email" /> <g:submitButton name="save" value="Save" /> </g:form> What modifications do i have to make in both the controller and the gsp page to render the