grails-2.0

Modularize Grails Application (Grails 2.3.x)

筅森魡賤 提交于 2019-12-04 20:52:42
I want to start my first project in Grails and I want to split in more application/plugins. For now I have only one site/application ( /myproj/projectA ). In the future I want to add a new application ( /myproj/projectB ) and I want to reuse some of logic of projectA (Ex. UserService). In Grails, what is the way? Create 2 applications ( projectA, projectB ) and one common (ex.with UserService) plugin? How do it? The final result is : I want to update single application without redeploy entire application. Thanks in advance Creating reusable/shared functionality is one of the key advantages of

dateCreated, lastUpdated fields in Grails 2.0

与世无争的帅哥 提交于 2019-12-04 17:41:47
问题 I've got an application that was using Grails 1.3.7 which I've just migrated to Grails 2.0. The application makes use of the automatic dateCreated and lastUpdated fields to manage the timestamps associated with creation and modification of the objects. After upgrading, I get the following error: | Running Grails application | Error 2012-01-29 22:36:53,504 [Thread-8] ERROR util.JDBCExceptionReporter - ERROR: null value in column "date_created" violates not-null constraint | Error 2012-01-29 22

Do Grails tests run in test environment by default?

雨燕双飞 提交于 2019-12-04 16:53:59
Is it necessary to supply the environment as grails test test-app ? Grails tests do run in the test environment by default. In general Grails commands default to dev if not specified, but the test-app command overrides the environment to test if none was specified, and the war command defaults to prod if not specified. 来源: https://stackoverflow.com/questions/25287173/do-grails-tests-run-in-test-environment-by-default

belongsTo multiple Domain

眉间皱痕 提交于 2019-12-04 16:31:36
I have 4 classes, incidents,problems, requests and another is Attachment. Every domain look like......... Class Incidents { // other fields static hasOne = [attachment: Attachment] static constraints = [attachment nullable:true] } Class Problems { // other fields static hasOne = [attachment: Attachment] static constraints = [attachment nullable:true] } Class Requests { // other fields static hasOne = [attachment: Attachment] static constraints = [attachment nullable:true] } Class Attachment { // other fields static belongsTo= [ incident: Incidents, problem: Problems, requests: Requests ]

How to conditionally disable a form input field

*爱你&永不变心* 提交于 2019-12-04 11:46:37
Say I have a Domain object Teacher with two fields String name, TeacherType teacherType, where TeacherType is an enum containing AssitantProfessor, AssociateProfessor, Professor. After I generate the views using grails run-target generate-all Teacher, it produces an _form.gsp that is used for both create and edit of Teacher. In the edit view I want only the name to be editable but the TeacherType to be unmodifiable once created (this is just an example, it is a requirement that certain fields can't be updated after creation). In the create view, both TeacherType and name should be editable.

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

[亡魂溺海] 提交于 2019-12-04 09:31:54
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.Specification @TestFor(VController) @Mock(VService) class VControllerSpec extends Specification { void

Grails conditional nullable validation or custom validator with nullable option

你说的曾经没有我的故事 提交于 2019-12-04 06:42:31
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 a validator on the province: province validator: {val, obj -> if (obj.country in obj

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

て烟熏妆下的殇ゞ 提交于 2019-12-04 03:25:57
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? 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 [from the bin directory ( sh startup.sh )] Second Method: leave your war file in CATALINA_BASE/webapps ,

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

流过昼夜 提交于 2019-12-04 00:43:28
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 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-where-to-put-test-files-and-how-to-load-them

Grails: log stacktrace to stdout

泄露秘密 提交于 2019-12-03 19:39:08
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 attempting to create the stacktrace.log file - it just redirects where stack traces are written to. And