Questions tagged [grails-controller]

This tag is about the controllers in Grails Open Source Framework technology.

Grails is an Open Source, full stack, web application framework for the JVM. It takes advantage of the Groovy programming language and convention over configuration to provide a productive and stream-lined development experience.

This tag is about the controllers in Grails technology.

467 questions
4
votes
1 answer

Grails 4.1.1 Data Service cannot be injected into Command Object: NoSuchBeanDefinitionException

I Have a simple design of Controller/Command/Data Service: @Secured("ROLE_BACKEND") class CommunityController { static namespace = "api" static allowedMethods = [index: "GET"] def index(GetCommunitiesRequest request) { respond…
Luis Muñiz
  • 4,649
  • 1
  • 27
  • 43
4
votes
1 answer

Why does a forwarded request pass through filter chain again?

I implemented not usual architecture for Grails app because I made front controller which only forwards requests further (based on some criteria). I also implemented locale resolver as a http servlet request filter. And it turned out that forwarded…
emstol
  • 5,966
  • 6
  • 27
  • 32
4
votes
1 answer

Grails does not pass variables to nested templates

When I render a view from a controller, variables passed to the view are in the scope of all templates rendered in the view, including templates nested several levels deep. However, when I render a template from a controller (as in ajax style), only…
Quad64Bit
  • 568
  • 7
  • 16
4
votes
1 answer

Grails beforeInterceptor with 2 actions

Can we define 2 different actions in beforeInterceptor of a Grails controller? I have a controller with below beforeInterceptor: def beforeInterceptor = [action:this.&debug] def trimParams() { params?.each { it = it.toString().trim() } } def…
Đinh Hồng Châu
  • 5,300
  • 15
  • 53
  • 90
4
votes
2 answers

Grails render v respond - conventions for passing to data to the controller

Some of the Grails conventions for passing data from the controller to the view I find a bit opaque notwithstanding reading the documentation. A few basic questions: Here are some questions: 1) in the scaffolding created for a 'Person'…
GGizmos
  • 3,443
  • 4
  • 27
  • 72
4
votes
1 answer

How to redirect from a controller using a named URL mapping?

I have a URL mapping as below: static mappings = { name register: "/register" { controller = "account" action = "createuser" } } and I want to redirect using this mapping from a controller with something…
fabien7474
  • 16,300
  • 22
  • 96
  • 124
4
votes
2 answers

redirect in Grails controller

I'm new to Grails , i'm using Grails version 2.3.4 , in my application i have 2 controllers AppUser and ManageLicences , in the AppUsers there is a method named auth and below its code : def auth() { if (!params.username.empty) { …
SShehab
  • 1,039
  • 3
  • 17
  • 31
4
votes
1 answer

Grails 2.4.2 - Dynamically referencing default datasource

This question has been partly answered here but there is still an issue with referencing the default datasource dynamically. I'm working on an internal application that allows developers to modify configuration settings for one of our multi-tenant…
4
votes
1 answer

How to obtain handle to Grails datasource

I want a handle to connection object in grails controller class (written in groovy). I read somewhere that I need to first obtain datasource object and call a method getConnection on it to get the connection object. I am unable to find how to…
Vishal
  • 41
  • 1
  • 2
4
votes
2 answers

How does flash object map work inside grails framework

Flash, which is a temporary storage map for one request. I am wondering how this is implemented on the grails core framework In particular I'm interested in the class(es) responsible for putting the flash map in the request and then taking it out…
Anthony
  • 33,838
  • 42
  • 169
  • 278
4
votes
1 answer

Add custom headers to response after "render as JSON"

I am trying to add a custom HTTP header to the response of a certain set of controllers using Grails Filters: class ApiFilters { def filters = { xwingFilter(uri:'/api/**') { after = { response.setHeader('X-Wing',…
chozero
  • 411
  • 6
  • 12
4
votes
2 answers

How to migrate Grails 2.1 to Grails 2.3 application?

I am migrating my application from Grails 2.1 to 2.3. I am getting lot of errors after migration - I want some sample applications with Grails 2.3 and Spring integration. I did some HelloWorld sample applications, and those are working fine. But…
Sun
  • 3,444
  • 7
  • 53
  • 83
3
votes
1 answer

Domain class hasMany fails to add entry

I'm a Grails noob so please excuse my noob question. I've created a domain classes User and Device. User hasMany devices:Device, and Device belongsTo user:User. It is important that only 1 device will never belong to two users so my UserController…
Nadav
  • 1,167
  • 2
  • 19
  • 43
3
votes
1 answer

Use grailsApplication injection inside UrlMappings

For some reason I get a huge list of errors when using following code: class UrlMappings { static grailsApplication static mappings = { grailsApplication.controllerClasses.each { controllerClass -> // FAILS! …
Faizan S.
  • 8,634
  • 8
  • 34
  • 63
3
votes
2 answers

Grails redirect breaks params types

My Grails code has a search function that redirects to another controller action after performing a findAllBy query: def results = Foo.findAllByBar(baz) redirect(action: "result", params: [results: results]) findAllByBar returns an ArrayList with…
user915495
1 2
3
31 32