controller

STS (Spring Tools Suite) 2.7.2 @RequestMappings View not displaying

穿精又带淫゛_ 提交于 2019-12-04 07:16:05
Currently Using: Spring Tools Suite v2.7.2 Spring Framework v3.0.5 Sample Code in a controller: @RequestMapping( value={ "/en/page", "/fr/page" }, method = { RequestMethod.POST }) Steps to reproduce issue in STS: [Menu] Window -> Show View -> @RequestMappings [Project] Right Click -> Spring Tools -> Show RequestMappings Returns: Javadoc content is missing or empty Question: How can I populate all @RequestMappings to view all urls mapped in my web application? To resolve, you must: Right click your project Spring Tools Add Roo Project Nature Then: Right click your project Spring Tools Show

AppDelegate or AppController

家住魔仙堡 提交于 2019-12-04 06:56:00
While reading cocoa tutorials i've noticed that some of the tutorials use AppDelegate and some AppController for defining IBActions that open various windows that use subclasses of NSWindowController . Is there some sort of rule of thumb for this? It's just a class name. AppDelegate implies that the class's main duty is as NSApplication's delegate, whereas AppController seems to imply a broader range of responsibility. I create one class that is solely my app delegate, and instantiates my main controller (in applicationWillFinishLaunching: ) and releases it (in applicationWillTerminate: ).

How can I create the Route in Kohana 3.2 for this directory structure: /application/my_use_case/classes/

三世轮回 提交于 2019-12-04 06:43:47
问题 I'm using Kohana 3.2 and I need to create the directory structure below for my application. For that, I'm using the Route below, but I'm doing something wrong yet. "Settings" is my use case that I'm developing. <?php Route::set('global', '<directory>(/<controller>(/<action>))', array('directory' => 'settings')) ->defaults(array( 'directory' => 'settings', 'controller' => 'settings', 'action' => 'index', )); ?> So, this is my directory structure for "Settings" use case: - ..\application

Unit testing a controller method?

爷,独闯天下 提交于 2019-12-04 06:43:04
I have a controller method like such: def search = { def query = params.query ... render results as JSON } How do I unit test this? Specifically, how do I call search to set params.query , and how do I test the results of the method render ? Is there a way to mock the render method, perhaps? Subclass grails.test.ControllerUnitTestCase for your unit tests. Grails will automatically instantiate your controller and mock out versions of render and redirect that allow you to test the results easily. Just assign the test inputs to controller.params to set up the test. Example: class

Rspec Controller tests, passing JSON params

六月ゝ 毕业季﹏ 提交于 2019-12-04 06:32:48
I'm trying to achieve the following: create a POST json request within RSpec Controller test, passing it params. Here's my code it 'returns access_token' do post :login, email: 'bla', password: 'bla1', format: :json end What I get in controllers request.body.read is a string with params, but passed like this email=bla&password=bla1 This is definitely not a JSON. But, if I make request using CURL curl -d '{"email": "bla@bla.com" }' http://127.0.0.1:3000/users/login --header "Accept: application/json" --header "Content-Type: application/json" I get my request.body.read as a correct json "{\

Error - Template is missing, unable to have 2 show views for the same posts

巧了我就是萌 提交于 2019-12-04 06:28:49
问题 This is a follow up question to: Rendering different views in one action The error I am getting is: Template is missing Missing template items/show, application/show with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. It should be noted, that I copied the show.html.erb file to two files show_with_edit.html.erb and show_with_star.erb , and deleted show.html.erb to avoid duplicates. My Code in posts_controller.rb def show if signed_in? show_signed_in else show_not

Spring 3 MVC Controller integration test - inject Principal into method

那年仲夏 提交于 2019-12-04 06:19:08
As part of Spring 3 MVC it is possible to inject the currently logged in user (Principle) object into a controller method. E.g. @Controller public class MyController { @RequestMapping(value="/update", method = RequestMethod.POST) public String update(ModelMap model, Principal principal) { String name = principal.getName(); ... the rest here } } This is documented as part of the Spring 3 documentation here: http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html#mvc-ann-requestmapping-arguments . This works in the production code. However I don't know how to

Nodejs: returning result on async result

我怕爱的太早我们不能终老 提交于 2019-12-04 05:59:32
问题 I'm trying to code an RESTfull API in nodejs which is basically around a controller/modele schema and I meet some problems about the async nature of nodejs: Station.js: (controller) 'use strict'; var url = require('url'); var Stations = require('./StationsService'); module.exports.stationsGet = function stationsGet(req, res, next){ var result = Stations.stationsGet(req.swagger.params['arg']); if(typeof result !== 'undefined') { res.setHeader('Content-Type', 'application/json'); res.end(JSON

@Autowired is not working with jersey and spring

你。 提交于 2019-12-04 05:48:18
问题 When I am running test at that time @Autowired is working but when I run the web app and try to fetch data at that time its throwing null pointer exception. this is my controller In this BuyerRepo is always null import com.retail.exception.InvalidIdException; import com.retail.model.Buyer; import com.retail.repository.BuyerRepo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.ws.rs.GET; import javax.ws.rs.Path;

How to render partial view in controller for Json

核能气质少年 提交于 2019-12-04 05:40:45
问题 I'm wondering how can I render a partial view to be used in a JsonResult in my controller? return Json(new { Html = this.RenderPartialView("_EditMovie", updatedMovie), Message = message }, JsonRequestBehavior.AllowGet); } 回答1: RenderPartialView is a custom extension method which renders a view as a string . It wasn't mentioned in the article (what you have referred originally) but you find it in the sample code attached to the article. It can be found under the \Helpers\Reders.cs Here is code