Try this response.sendError 403 and make sure you have created controller and action as in your URL mapping and rendered something from action....
grails,grails-controller,grails-filters
Take a look at the documentation and you will see that you have access to the controller name in controllerName and many other values. If you need the entire class name you can find it through: grailsApplication.getArtefactByLogicalPropertyName("Controller", controllerName).clazz ...
hibernate,grails,grails-domain-class,grails-controller,grails-validation
I'd probably use something like this: validator: { val, obj -> if (obj.recipients.findAll{invoiceType == 'O'}.size() > 1) return "invoiceRecipient.original.max.exceed" This way you should be able to prevent Hibernate from trying to flush dirty objects and in the process revalidate this object....
grails,grails-2.0,gsp,taglib,grails-controller
pageScope. As for the usage in your company code, I guess it depends on how long ago it was written. Referring to docs in 2010 like: grails_pagescope_variable_in_gsps_and_taglibraries and overriding-plugin-templates-in-grails-application there are a few more around people were using it then, can't comment on if it was essential back then.
grails,httprequest,grails-controller
I have found the perfect solution right here: Grails pass data to view from controller in PropertiyController.groovy: def index = { def parameter = request.getParameter("address") } and: def create() { def address = params.address; render(view: "form", model:[viewAddress:address]); } The only thing to change additional is to give the input-field the...
grails,integration-testing,grails-controller,spring-tool-suite,syntactic-sugar
Looks like it was test pollution as evidenced by my edit 'When I run the test via command line by itself the test will pass, but if I run all the integration tests it fails'. Turns out other integration tests where using @TestFor and @Mock in them, which you should...
If you have the code inside a controller action, you have to keep an eye on 2 things: transactionality (with try/catch/finally etc) what should the action return/render in case of TX-success/-failure. It's complicated enough, so you should put the service calls into another service method, where you have to deal...
In your Merchant domain class you can add the following method to intercept an update event and if the email property has changed update the corresponding username. Off the top of my head it will look something like this: def beforeUpdate() { if (this.getDirtyPropertyNames().contains('email')) { this.login.username = this.email } }...
grails,gorm,grails-2.0,grails-domain-class,grails-controller
You can construct the drop down list on Service/Controller and pass via modal to gsp page and use. The controller/service method will look like: def c = AdtAuditorSchdlPack .createCriteria() def results = c.list() { and{ // your criteria logic } order('id', 'asc') } Construct the list based on your logic:...
grails,groovy,gorm,grails-domain-class,grails-controller
If you want to get all the entries that are active, change the from attribute to: from="${Pagadora.findAllByActivo(true) [sort: 'nombre', order: 'asc']}" This is a dynamic finder. Jeff points out in the comments that the boolean parameter here can be omitted (see examples for findAllBy). If you want to get all...
What about simply excluding /demo/index from mapping like this: static excludes = ['/demo/index'] ...
unit-testing,grails,grails-domain-class,grails-controller
import grails.test.mixin.Mock import grails.test.mixin.TestFor import spock.lang.Specification @TestFor(AuthorController) @Mock([Author]) class AuthorControllerSpec extends Specification { void "when index is called, authorPage view is rendered"() { when: controller.index() then: view == "/author-page" } } Try this....
Make sure that grails-app/views/hello/index.gsp file exists.
grails,groovy,gsp,grails-controller,grails-services
You haven't shown the GSP code that displays the row, but I guess it looks like either ${it} or ${row}. If so, replace it with either ${it.cname} or ${row.cname}...
grails,null,save,grails-domain-class,grails-controller
Well I managed to solve it... Apparently new DeviceUsage(device: deviceInstance, user: User.get(user), start: new Date(), end: null) leaves start null for whatever reason, so adding du.start = new Date() at the next line fixed it...
grails,constraints,grails-domain-class,grails-controller
That's quite simple to make a unique property. For example: static constraints = { healthService(unique: ['doctor']) } The above will ensure that the value of healthService is unique for each value of doctor within your domain class....
The problem was with the instance variable def usr = DbUser.findByLoginNameIlike(session.username) // Find DbUser reference to the current user When DashboardController is instantiated, it tries to execute the above line where no session is stored yet (session.username is NULL). Moving this piece of code inside the methods solved the problem....
You can use render method of PageRenderer class, like PageRenderer groovyPageRenderer def someMethodOrAction(){ groovyPageRenderer.render(view: 'myView', model: someParamsIfAny) } ...
grails,grails-controller,url-mapping,grails-3.0
Grails has the possibility to declare namespaces for Controllers. With this, you can put all your controllers under the namespace 'app', which should result in exactly your second question. See docs for more details. The security restriction then be accomplished with normal spring security settings (@Secured e.g)....
ajax,grails,render,gsp,grails-controller
I don't think I entirely understand your question, but I think the source of your confusion is that the way you are naming things doesn't follow regular conventions and you're not using the right tools for the job. Let me explain... The methods on Controllers are called Actions. They send...
hibernate,grails,grails-controller
The best way to do this is not to use discard() but instead to use transactions and the native transaction features of your database. I would recommend moving the logic into a service (separating your controller flow code and the logic of your application. Example: class GroupService { @Transactional void...
grails,model-view-controller,gsp,grails-controller
In your controller put your code like below and see what happens. render( view: "/foo/foo", model: ) If your controller name and the view folder are same then you dont need to give /foo/foo. Just writing "foo" should be fine. PS. I have not tried this now, but it should...
grails,grails-domain-class,grails-controller,grails-services
You've spelled hasMany wrong in your Customer domain. static hastMany = [awards:Award, orders:OnlineOrder] should be static hasMany = [awards:Award, orders:OnlineOrder] ...