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
39
votes
4 answers

Inject grails application configuration into service

I'm creating a grails service that will interact with a 3rd party REST API via a Java library. The Java library requires credentials for the REST API by means of a url, username and password. I'd like to store these credentials in…
Jon Cram
  • 16,609
  • 24
  • 76
  • 107
34
votes
1 answer

Grails controller rendering method render vs respond

I just realised that for a Grails controller there is another rendering method 'respond'. What's the difference between respond and render method if we want to render a view in the controller.
ttt
  • 3,934
  • 8
  • 46
  • 85
26
votes
5 answers

How do you share common methods in different grails controllers?

Currently when I need to share a method like processParams(params) between different controllers, I use either inheritance or services. Both solution has some inconvenients : With inheritance, you cannot use multiple inheritance which means that…
fabien7474
  • 16,300
  • 22
  • 96
  • 124
19
votes
3 answers

Grails: Services VS Groovy classes

Documentation says: The Grails team discourages the embedding of core application logic inside controllers, as it does not promote re-use and a clean separation of concerns. I have one API controller and a few Groovy classes in src/groovy…
Oleksandr
  • 3,761
  • 8
  • 50
  • 80
16
votes
5 answers

How to do a Union SQL statement in HQL?

I'm trying to create a Union between two tables, using HQL (Hibernate Query Language). This SQL script works fine on my SQL server: SELECT COUNT(DISTINCT linkedin_id) as test, school_name FROM (SELECT * FROM alum_education UNION SELECT * FROM…
jason
  • 3,821
  • 10
  • 63
  • 120
14
votes
4 answers

Grails. Could not resolve view with name 'index' in servlet with name 'grailsDispatcherServlet'

I'm getting started with Grails (3.x) Framework but I got stuck with this error while trying to render domain content to a view: Error 500: Internal Server Error URI /hello/index Class javax.servlet.ServletException Message: Could not resolve view…
Gerardo Tarragona
  • 1,185
  • 4
  • 15
  • 28
14
votes
1 answer

Groovy Grails, How do you stream or buffer a large file in a Controller's response?

I have a controller that makes a connection to a url to retrieve a csv file. I am able to send the file in the response using the following code, this works fine. def fileURL = "www.mysite.com/input.csv" def thisUrl = new URL(fileURL); …
Julian Noye
  • 141
  • 1
  • 1
  • 3
13
votes
3 answers

How to force grails to download csv files?

In my gsp view, I have this code : ${fileResourceInstance.decodeURL()}
Fabien Barbier
  • 1,514
  • 4
  • 28
  • 41
12
votes
1 answer

How can I list the available objects to inject in grails?

Is there a way to programatically list all available beans in the grails spring injection context? In guice I was able to do this by looking up the bindings configured in the injector.
benstpierre
  • 32,833
  • 51
  • 177
  • 288
12
votes
3 answers

Grails Command Object: How to load request.JSON into it?

Question: is there a way to do automatic command object binding with request.JSON data? Given this simple Command object in my grails controller: class ProfileCommand{ int id String companyName static constraints = { companyName blank: false …
John Gordon
  • 2,181
  • 5
  • 28
  • 47
10
votes
1 answer

how to use session in grails

I am new to grails. And I have to work with session. I have seen the session documentation. But no idea where to put the code in my controller. I have a page for student creation names createStudent. Now I want that this page only be access able…
Sumon Bappi
  • 1,937
  • 8
  • 38
  • 82
8
votes
2 answers

Why does Grails require that I use `def` instead of `void` in a controller?

Take the following controller: package test class TestController { static defaultAction = "test" def test() { render "test" } } Why is test defined with def test() { instead of something like void test() {? Isn't the def…
Tom Marthenal
  • 3,066
  • 3
  • 32
  • 47
8
votes
1 answer

Why does Grails recommend singleton scope for controllers with actions as methods?

I know early versions of Grails used prototype scope for controllers because actions were all closures at that time. I know that the current version documentation recommends singleton scoped controllers for controllers that use methods as…
DAC
  • 707
  • 1
  • 6
  • 20
7
votes
3 answers

Using JSON to create an object in Groovy/Grails

I have a Groovy/Grails website that is being used to send data to Android clients via JSON. I have created both the Android client and the Groovy/Grails website; and they can output the same objects in JSON. I can successfully create the respective…
chrisburke.io
  • 1,497
  • 2
  • 17
  • 26
7
votes
3 answers

How to extend/override controller actions of plugins?

The plugin (Nimble 0.3) I am using in my grails application, includes some controllers and associated actions. I want to change (slightly) some actions behavior, and I was wondering how I can achieve that. Can I create a child controller that…
1
2 3
31 32