grails-2.0

Grails unit tests: Accessing defined beans via grailsApplication

非 Y 不嫁゛ 提交于 2019-12-22 14:16:12
问题 I have some (non-Grails-artifact) classes that access the service layer beans via passing around the grailsApplication object. However I'm having trouble unit testing the classes implemented in this way. Why doesn't the bean get registered in the main context? @TestMixin(GrailsUnitTestMixin) class ExampleTests { void setUp() {} void tearDown() {} void testSomething() { defineBeans { myService(MyService) } assert grailsApplication.mainContext.getBean("myService") != null } } The above code

How to set formula in grails domain class?

烈酒焚心 提交于 2019-12-22 13:04:50
问题 I am trying to write formula in my domain class which helps me in creating criteria. class MyClass { //some fields Date appointmentTime String ddmmyy int year int month int day static transients = [ 'ddmmyy', 'year', 'month', 'day' ] static mapping= { ddmmyy formula('DATE_FORMAT(appointmentTime)') year formula('YEAR(appointmentTime)') month formula('MONTH(appointmentTime)') day formula('DAYOFMONTH(appointmentTime)') } } Whenever I am trying to use this fields in my criteria it throws error i

How to set formula in grails domain class?

帅比萌擦擦* 提交于 2019-12-22 13:03:08
问题 I am trying to write formula in my domain class which helps me in creating criteria. class MyClass { //some fields Date appointmentTime String ddmmyy int year int month int day static transients = [ 'ddmmyy', 'year', 'month', 'day' ] static mapping= { ddmmyy formula('DATE_FORMAT(appointmentTime)') year formula('YEAR(appointmentTime)') month formula('MONTH(appointmentTime)') day formula('DAYOFMONTH(appointmentTime)') } } Whenever I am trying to use this fields in my criteria it throws error i

How to set formula in grails domain class?

心不动则不痛 提交于 2019-12-22 13:03:06
问题 I am trying to write formula in my domain class which helps me in creating criteria. class MyClass { //some fields Date appointmentTime String ddmmyy int year int month int day static transients = [ 'ddmmyy', 'year', 'month', 'day' ] static mapping= { ddmmyy formula('DATE_FORMAT(appointmentTime)') year formula('YEAR(appointmentTime)') month formula('MONTH(appointmentTime)') day formula('DAYOFMONTH(appointmentTime)') } } Whenever I am trying to use this fields in my criteria it throws error i

Grails default package name

十年热恋 提交于 2019-12-22 07:07:30
问题 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. 回答1: If I

Modularize Grails Application (Grails 2.3.x)

China☆狼群 提交于 2019-12-22 00:41:22
问题 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

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

is handling custom server side errors in ember-data when saving model possible

与世无争的帅哥 提交于 2019-12-21 04:52:09
问题 Is there proper way to handle custom error when saving a model? To give an example, lets say I have a model with just two properties "name" and "value". And when I do : var myModel = this.get('store').createRecord('myModel', {"name": "someName", "value": "someValue"}); myModel.save().then(function() { //if success //server responded with {"myModel:{"id":1,"name":"someName","value":"someValue"}"} },function() { //if failure //server responded with {"error":"some custom error message"} //BUT

Fastest way to read/write Images from a File into a BufferedImage?

与世无争的帅哥 提交于 2019-12-20 20:37:53
问题 What is the fastest way to read Images from a File into a BufferedImage in Java/Grails? What is the fastest way to write Images from a BufferedImage into a File in Java/Grails? my variant (read): byte [] imageByteArray = new File(basePath+imageSource).readBytes() InputStream inStream = new ByteArrayInputStream(imageByteArray) BufferedImage bufferedImage = ImageIO.read(inStream) my variant (write): BufferedImage bufferedImage = // some image def fullPath = // image page + file name byte []

In Grails, how do I display validation error messages next to the fields?

梦想的初衷 提交于 2019-12-20 17:39:32
问题 The Grails 2.0.4 documentation for validation shows you how to display error messages at the top of the page and how to add a css class to an element if a field is invalid, but it doesn't tell you how to display the error message next to the fields themselves, something like this: ----------------------- Name: | | You must enter a name! ----------------------- How do you retrieve the specific error message for an invalid field and then display it next to the field it's for? 回答1: Actually, the