grails-controller

How to access command objects from filter and is it possible at all?

[亡魂溺海] 提交于 2020-01-13 19:11:36
问题 I often write something like: def myAction{ MyActionCommand cmd -> if( cmd.hasErrors() ){ return render(status:HttpServletResponse.SC_BAD_REQUEST ); }else{ // actual action logic } So, I'd like to extract that common pattern into some reusable location. Filter looks like good candidate, but I can't find the way to get command object from the filter. Tryed something like this (in filters closure): formValidation( controller:'*', action:'*' ){ before = { cmd -> if( cmd.hasErrors() ){ response

How to access command objects from filter and is it possible at all?

纵然是瞬间 提交于 2020-01-13 19:11:11
问题 I often write something like: def myAction{ MyActionCommand cmd -> if( cmd.hasErrors() ){ return render(status:HttpServletResponse.SC_BAD_REQUEST ); }else{ // actual action logic } So, I'd like to extract that common pattern into some reusable location. Filter looks like good candidate, but I can't find the way to get command object from the filter. Tryed something like this (in filters closure): formValidation( controller:'*', action:'*' ){ before = { cmd -> if( cmd.hasErrors() ){ response

How to access command objects from filter and is it possible at all?

不羁的心 提交于 2020-01-13 19:11:06
问题 I often write something like: def myAction{ MyActionCommand cmd -> if( cmd.hasErrors() ){ return render(status:HttpServletResponse.SC_BAD_REQUEST ); }else{ // actual action logic } So, I'd like to extract that common pattern into some reusable location. Filter looks like good candidate, but I can't find the way to get command object from the filter. Tryed something like this (in filters closure): formValidation( controller:'*', action:'*' ){ before = { cmd -> if( cmd.hasErrors() ){ response

Grails 2.2.0 Support in Eclipse

亡梦爱人 提交于 2019-12-30 06:51:09
问题 I am trying to create a grails 2.2.0 project using eclipse-jee-juno. It gives me an error Groovy compiler level expected by the project does not match workspace compiler level. Project compiler level is: 1.8.X Workspace compiler level is 1.7.X Go to Project properties -> Groovy compiler to set the Groovy compiler level for this project. Background : I have installed grails 2.2.0 and I am able to create and run a sample project/controller by using the command line (not eclipse) 回答1: Grails 2.x

Accessing the data in db via Domain class in Controller via grails testing

筅森魡賤 提交于 2019-12-25 08:43:06
问题 def index() { //println params String params_key =params['key'] def c = get_value(params_key) def resp = ['key': params_key, 'value':c] render resp as JSON } private static hash_conv(String value) { def matches = Eval.me(value.replace(':','').replace('{','[').replace('=>',':').replace('#','//').replace('}',']')) return matches } private get_value(String key, default_value=null){ def app_preferences = get_preferences() def result = app_preferences[key] if (result == null) { result = default

Why does a forwarded request pass through filter chain again?

☆樱花仙子☆ 提交于 2019-12-23 15:31:05
问题 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 request passes again through filter chain. So flow looks like this: A request arrives to grails app The request passes through my filter The front controller gets the request and forwards it further The forwarded request passes again through my

Grails, how to find by a record by its foreign key

…衆ロ難τιáo~ 提交于 2019-12-21 12:33:52
问题 I have two domains that are a part of a one-to-many relations ship. I was wondering how i can query the child for the parents FK? bellow is the psuedo-code for parent/child Parent: class AlumProfile { String firstName String lastName static hasMany = [alumLanguage : AlumLanguage] static mapping = { cache true id generator: 'assigned' columns { firstName type:'text' lastName type:'text' } // } static constraints = { firstName (nullable:true) lastName (nullable:true) } } Child: class

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

只谈情不闲聊 提交于 2019-12-21 09:28:57
问题 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 actions. From the following post it seems that methods and singleton scope are more desirable or recommended, but it's not clear why. ttp://grails.1312388.n4.nabble.com/Default-scope-for-controllers-doc-td4657986.html We have a large project that uses

How to migrate Grails 2.1 to Grails 2.3 application?

守給你的承諾、 提交于 2019-12-21 05:16:37
问题 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 even I apply same thing in my application, even some where it is giving error. Because my application is very big(100mb) and i am using lot of integration with Spring, Hibernate, and lot of Grails plugins. I did not find any code level document for

Grails Redirect Post-Logout Using spring-security-core-3.0.6+

天大地大妈咪最大 提交于 2019-12-19 03:20:09
问题 In spring security version 3.0.6, which fixed a CRLF logout exploit (https://jira.springsource.org/browse/SEC-1790) they disabled the use of the 'spring-security-redirect' parameter. Default support for the redirect parameter in logout URLs has also been removed in 3.0.6. In 3.1 it already needs to be enabled explicitly. Is there a way to turn the redirect parameter back on, so that I can dynamically redirect in my Grails Spring Security Logout Controller? LogoutContoller.groovy def user =