grails

Is it possible to get a List of all active Sessions?

时光怂恿深爱的人放手 提交于 2020-01-04 04:07:13
问题 When being in a Grails action I can access a HTTPSession with session . Is it also possible to get a list of all active sessions? 回答1: You can use getSessionsInfo() method of ScopesInfoService service of Application Info plugin. First install plugin(in BuildConfig) compile ":app-info:1.0.2"{ excludes 'jquery' } then make an entry in Config grails.plugins.appinfo.useContextListener = true finally inject service and use its getSessionsInfo() method def scopesInfoService ... scopesInfoService

Grails 3: External Logback.groovy file

纵然是瞬间 提交于 2020-01-04 03:54:14
问题 I'm trying to externalize my logback.groovy file by setting the path in my build.gradle file in the bootrun closure: bootRun { if (Environment.currentEnvironment == Environment.PRODUCTION) { jvmArgs = ['-XX:MaxPermSize=2g', '-Xmx2g', '-Dlogging.config=/path/to/config/logback.groovy'] } else { jvmArgs = ['-XX:MaxPermSize=2g', '-Xmx2g'] } } But I am getting: .logback.classic.LoggerContext[default] - Found resource [logback.groovy] at [file:/Users/name/workspace/project/build/resources/main

Passing state between pages when using geb & spock

牧云@^-^@ 提交于 2020-01-04 03:27:07
问题 In the example below (Taken from the Book of Geb), we're clicking on a button that takes us to another page. class GoogleHomePage extends Page { static url = "http://google.com" static at = { title == "Google" } static content = { searchField { $("input[name=q]") } searchButton(to: GoogleResultsPage) { $("input[value='Google Search']") } } } Browser.drive(GoogleHomePage) { searchField.value("Chuck Norris") searchButton.click() assert at(GoogleResultsPage) assert resultLink(0).text() ==~

AJAX post JSON data from Javascript to Grails

为君一笑 提交于 2020-01-04 01:58:13
问题 I'm trying to POST JSON formatted data from Javascript (using Prototype) to Grails. My Javascript code is: var JSONObject = new Object; JSONObject.id = "23"; JSONObject.name = "Test 1"; JSONstring = JSON.stringify(JSONObject); var url = "${createLink(controller:'testController', action:'receiveJson')}"; new Ajax.Request(url, { method:'post', contentType:'application/json', parameters:JSONstring, asynchronous:true, onSuccess: function (req) { sendInfoResponse(req.responseText); } }); and the

How to handle errors that occur in @BindUsing annotation closure

て烟熏妆下的殇ゞ 提交于 2020-01-04 01:36:09
问题 I have a property with custom data binding like this: class User { // Custom data binding for the image @BindUsing({ obj, source -> def imageFile = source['image'] if (imageFile && imageFile.size > 0) { Document image = obj.image ?: new Document() image.setFile(imageFile) if(!image.save()) { throw new Exception('Non localizable message') } return image } }) Document image ... } If an exception is thrown (like in my example) it is converted to a ValidationException with always the same generic

How to incorporate a g:link into an ordinary button?

↘锁芯ラ 提交于 2020-01-03 18:42:42
问题 In my grails application there is a view with a a g:link tag - it works fine, but the visuals are kind of awkward. Therefore, I want to disguise that g:link with an ordinary button. I've tried a span class and input type="button" but this did not do the trick. Side note : I don't want a g:form with an submit action. Any help is really appreciated! 回答1: Amit Jain's answer worked but had some problems in ie 8 & 7 (looked like some kind of style overlapping error). This solution worked in all

grails list.gsp / g:sortableColumn: being able to sort on associated domain objects

≯℡__Kan透↙ 提交于 2020-01-03 17:44:47
问题 Lets say I have an Issues domain class and it has as a field assignedTo: String title String priority User assignedTo ... I need to be able to sort on assignedTo. Neither the list.gsp default scaffolding nor the tag it uses, g:sortableColumn, support this. It seems like the g:sortableColumn needs to have both a property field, and a propertyOfProperty field. Do you know a good way to solve this? 回答1: Ok, so this appears possible, just missing clarity in the documentation, and searching the

grails list.gsp / g:sortableColumn: being able to sort on associated domain objects

∥☆過路亽.° 提交于 2020-01-03 17:44:05
问题 Lets say I have an Issues domain class and it has as a field assignedTo: String title String priority User assignedTo ... I need to be able to sort on assignedTo. Neither the list.gsp default scaffolding nor the tag it uses, g:sortableColumn, support this. It seems like the g:sortableColumn needs to have both a property field, and a propertyOfProperty field. Do you know a good way to solve this? 回答1: Ok, so this appears possible, just missing clarity in the documentation, and searching the

Overwrite a plugin GSP and Controller within another Plugin

余生长醉 提交于 2020-01-03 16:24:26
问题 I have a fairly complicated grails plugin dependency structure within my project and I am having problems overriding classes from the security plugin. My structure is a little something like this: Web App |_ Audit Plugin |_ Spring Security Core Plugin |_ Security Wrapper Plugin |_ Audit Plugin |_ Spring Security Core Plugin The reason it is like this is audit is shared between some apps which have the security wrapper, and some what don't, which is why it pulls in Security-Core (it needs at

Overwrite a plugin GSP and Controller within another Plugin

丶灬走出姿态 提交于 2020-01-03 16:24:05
问题 I have a fairly complicated grails plugin dependency structure within my project and I am having problems overriding classes from the security plugin. My structure is a little something like this: Web App |_ Audit Plugin |_ Spring Security Core Plugin |_ Security Wrapper Plugin |_ Audit Plugin |_ Spring Security Core Plugin The reason it is like this is audit is shared between some apps which have the security wrapper, and some what don't, which is why it pulls in Security-Core (it needs at