grails-2.0

How to manage development in multiple grails/groovy version?

ぃ、小莉子 提交于 2019-12-06 06:36:35
问题 I have a project which uses groovy 1.7.5 and grails 1.3.4. but my new project yet start which will use latest version of groovy (1.8.6) and grails (2.0.4) i will be working in both project. so how to manage different versions of grails in Windows environment. i do not want to upgrade the project which uses old version of grails(1.3.4) 回答1: There are several ways to archieve automatic version switching for grails. I am not using windows, but a colleague of mine used a bat file for automatic

Unable to mock Grails Service method when unit testing Controller - MissingMethodException

故事扮演 提交于 2019-12-06 04:06:11
问题 Am getting the following error message when testing the controller - see below for code. How can I correct this? When I invoke the service method from the controller (run-app) and it works fine. Exception: groovy.lang.MissingMethodException: No signature of method: grails.test.GrailsMock.isOk() is applicable for argument types: (java.lang.String) values: [H] at ...VControllerSpec.test something(VControllerSpec.groovy:) class: VControllerSpec import grails.test.mixin.TestFor import spock.lang

Grails conditional nullable validation or custom validator with nullable option

与世无争的帅哥 提交于 2019-12-06 01:47:15
问题 I have a form to create a place. Depending of the country, the province (state, region) field is required or not. When is not required, I want to be null, not empty string. I have code that makes all empty form fields, null: def newparams = [:] place = new Place() params.each() { k, v -> if (v instanceof String && place.hasProperty(k)) { if (!v.trim().length()) { newparams[k] = null } else { newparams[k] = v } } } place = new Place(newparams) place.validate() Now, in the place domain, I have

How can I remove the application name from a Grails application’s URL?

和自甴很熟 提交于 2019-12-05 22:47:38
问题 I have an application running at a URL like this: http://myapp.mydomain.com/myapp I don’t want the /myapp part in the URL. So how can I get rid of the application name? I want just http://myapp.mydomain.com to be the URL. How can I do this? 回答1: bit detailed approach First Method: first shutdown your tomcat [from the bin directory ( sh shutdown.sh )] then you must delete all the content of your tomcat webapps folder ( rm -fr * ) then rename your WAR file to ROOT.war finally start your tomcat

Grails 2.4.4 Testing for permission where spring security code is being used

房东的猫 提交于 2019-12-05 18:32:02
I am using spock for may application testing and using Grails 2.4.4. I have done domain, controller, and service unit testing. But in controller sections I am stuck with the role wise access. For authentication I am using Spring Security Core Plugin. Below is my sample code. @Secured(["IS_AUTHENTICATED_FULLY"]) def index(Integer max) { } @Secured(["ROLE_A","ROLE_B"]) def create() { respond new DomainName(params) } @Transactional @Secured(["ROLE_A","ROLE_B"]) def save(DomainName DomainNameInstance) { } How do I test that only the user with ROLE_A and ROLE_B can create and save and other cannot?

Grails - Where to put test files and how to load them

元气小坏坏 提交于 2019-12-05 17:53:23
问题 I'd like to ask where is the best place for test files in grails (i.e. data.xml). Is it test/ folder? How can I load test files in Integration test easily? Thanks, Mateo 回答1: in test/integration/resources and then, i.e. if you use spock for testing, you can do something like that: def mediaBundlerService = Mock(MediaBundlerService) mediaBundlerService.getPath(_) >> [path: new File('test/integration/resources/test-bundle/').absolutePath + "/"] 来源: https://stackoverflow.com/questions/10739182

Grails default package name

五迷三道 提交于 2019-12-05 12:05:08
I am new to Grails and I like it very much. I want to place my classes in packages like org.company.project.module.model . Its quite painful for to me to repeat create-domain-class <package>.<class_name> . Is there something like "package templates" or can I somehow "enter" (like grails cd org.comopany... ) and then just write Class names ( grails Person will be generated in ./ location)? Is that possible or should I use copy paste design pattern? Thanks in advance for any help. Alidad If I understood your question, you are looking for default package name for your domain classes. In your

grails validate nested command object not working

我怕爱的太早我们不能终老 提交于 2019-12-05 08:17:25
I'm using grails 2.2.1 and attempting to validate a nested command structure. Here is a simplified version of my command objects: @Validateable class SurveyCommand { SectionCommand useful SectionCommand recommend SurveyCommand() { useful = new SectionCommand( question: 'Did you find this useful?', isRequired: true) recommend = new SectionCommand( question: 'Would you recommend to someone else?', isRequired: false) } } @Validateable class SectionCommand { String question String answer boolean isRequired static constraints = { answer(validator: answerNotBlank, nullable: true) } static

Groovy: compiler mismatch after installation

时光总嘲笑我的痴心妄想 提交于 2019-12-05 08:12:04
I am using grails 2.3.4 with the eclipse grails plugin(GGTS) . However, after installation I created a project and got: Description Resource Path Location Type Groovy: compiler mismatch Project level is: 2.1 Workspace level is 1.8 Groovy compiler level expected by the project does not match workspace compiler level. Go to Project properties -> Groovy compiler to set the Groovy compiler level for this project test test Groovy compiler mismatch problem I tried to change the compiler preferences but nothing changes... I really appreciate your answer! You can also add an extension from the Spring

Grails: log stacktrace to stdout

泪湿孤枕 提交于 2019-12-05 03:02:38
问题 When I launch my grails application, I get the following error: java.io.FileNotFoundException: stacktrace.log (Permission denied) I know this can be solved by chowning some files/directories or by changing the file the logs go to, but I don't want this: I just want stracktraces to be logged to the stdout. The documentation states: For example if you prefer full stack traces to go to the console, add this entry: error stdout: "StackTrace" However: it also states: This won't stop Grails from