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
3
votes
2 answers

Grails render() with a fragment parameter

Is there a way to use render() with a fragment param so on page load it automatically scrolls to a specific part of the page? Similarly to how we can call redirect(controller: "book", action: "show", fragment: "profile")
Slavko
  • 486
  • 3
  • 6
  • 12
3
votes
2 answers

Grails - cross controller code, execute on every request

Is there a way of executing some piece of code before any controller action gets called? I need to set a session variable based on the value of a get parameter, without taking into account which controller gets called. Of course, once this…
DanC
  • 8,595
  • 9
  • 42
  • 64
3
votes
1 answer

Grails 3.3.0 on Tomcat 7.0.57

We are trying to use response.outputStream in Grails 3.3.0 under Tomcat 7.0.57. However, when any bytes are written to the stream, we get this error: org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is…
Sean LeBlanc
  • 185
  • 2
  • 12
3
votes
0 answers

Grails Spring Security: move to another page when account is expired

I have implemented a web site with Grails 3.x and spring security 3.1. I can manage user registration and authentication in my login page. I'd like to manage the expiration account as well. If I have an account expired, login page says that you…
NiBE
  • 857
  • 2
  • 16
  • 39
3
votes
1 answer

Grails connect database fields

I'm trying to learn Grails but am still pretty much on beginner level. I made a tiny application, where you can basically add events, and people can write reviews about them and rate them. So I have an eventController and reviewController. The…
Silvie
  • 41
  • 1
  • 8
3
votes
1 answer

Cannot redirect for object [ManageVehicle : (unsaved)] it is not a domain or has no identifier. Use an explicit redirect instead

This is my domain. import org.apache.commons.lang.builder.EqualsBuilder import org.apache.commons.lang.builder.HashCodeBuilder class ManageVehicle implements Serializable { String vehicle Short truckKey=0 Short siteID Integer…
3
votes
2 answers

Grails: Unit testing controller method with domain class

I have a simple grails controller: class AuthorController { def index(){ def authors = Author.findByFirstName("Albert") render (view: "author-page", model: ["authors":authors]) } } Here, Author is a domain class that maps to…
Stealth
  • 1,559
  • 4
  • 16
  • 34
3
votes
1 answer

Test UrlMapping Paths for Resource Controllers

In Grails 2.3 and above, there is now the concept of a resource controller. However, they do not seem to work with the assertUrlMappings concepts. /foo (resources:"foo") Then in the url-mappings-report the following appears: Controller: foo | GET…
tmarthal
  • 1,498
  • 19
  • 28
3
votes
2 answers

Update template inside a view rendered from another controller

I am looking for the way to refresh a template inside a view rendered from another controller than the template's controller, I mean: I got two controllers AdminController & UserController. And two gsps /admin/listUsers & /user/_searchResult. Then a…
IgniteCoders
  • 4,834
  • 3
  • 44
  • 62
3
votes
2 answers

Grails 2.3.7 Rest API - Search/Query

I am using Grails 2.3.7. I have exposed my controller as REST controller by over riding the restfull controller interface. My client is AngularJS. My CRUD operations are working fine. I have now a requirement to write search API on various objects…
jd.tech20
  • 171
  • 1
  • 10
3
votes
1 answer

How to avoid extra parameters in grails (GSP page to Controller)

I am new with grails. In my web application I have a hidden field value of this hidden field is setting on Submit.
JiniKJohny
  • 1,172
  • 13
  • 29
3
votes
1 answer

Dynamic scaffolding of multiple domain classes with single controller

For my web application in grails I have 3 admin controlling domain classes and no need of special UIs. For this I have decided to use dynamic scaffolding. static scaffold = true; is scaffolding only one domain class. Is there any way to scaffold all…
3
votes
2 answers

(unsaved) data in groovy in many-many relationship

My Data Domain: class Course{ List teacherCourse static hasMany = [courseByMultipleTeacher:TeacherCourse] } class Teacher{ String name List teacherForCourses static hasMany = [teacherForCourses:TeacherCourse] } class…
matuda
  • 195
  • 2
  • 16
3
votes
1 answer

Sorting Parent and Child in Grails Controller

Hi I'm trying to perform a sort in a controller of parent and child before rendering a json file but I'm not sure how to go about doing it. Here's what I have (excerpt of original code): class Parent{ static hasMany = [children:Child] String…
codeBarer
  • 2,238
  • 7
  • 44
  • 75
3
votes
1 answer

Grails controllers with same name but in different package

I am using the latest version of Grails which is 2.3.2 In my application there are admin and public site. But both share the same User domain class for example. Here the problems come, I need to have two controllers for admin and customer. Obviously…
ttt
  • 3,934
  • 8
  • 46
  • 85