grails

how to delete index on mysql table ?

Hi, I have a table generated by GORM (Grails Domain). It has foreign key / index that generated random characters like FKAC7AAF67162A158F. I need to remove that field that not needed anymore. The problems, I have some servers that need to be updated. So I need to create a migration using Liquibase. But I have no idea how to remove that...

How to mock abstract class with static members in Grails?

I need to mock a GrailsControllerClass interface. Instance should have a static variable defined. The problem is that MockFor and StubFor don’t give you an option for adding static members. So, I write my abstract class that extends GrailsControllerClass abstract class MyController implements GrailsControllerClass { static myDefiniti...

Grails: problem with paging and ordering in a view template

How do I structure my pages and partial templates so that Ajax will play nice with <paginate> and column sorting? I currently have a search.gsp page with a remoteField that calls a controller to update a template. This all works fine. However, the column sorting and paging actions cause my search.gsp to be completely replaced by the tem...

Grails Webflow - keeping things *out* of flow scope

I'm missing something.... I have a Grails webflow that looks like this:- def childFlow = { start { action { def targets = [] Target.list().each {target -> targets.add(new TargetCommand(name: target.name, id: target.id)) } log.debug "...

Found shared references to a collection org.hibernate.HibernateException

Hi, I got this error message : error: Found shared references to a collection: Person.relatedPersons when I tried to save addToRelatedPersons(anotherPerson) : person.addToRelatedPersons(anotherPerson); anotherPerson.addToRelatedPersons(person); anotherPerson.save(); person.save(); my domain : Person { static hasMany = [relatedPe...

Which framework to choose?

Hello there, I was thinking which framework would be a good choice to go into. I'm focusing on java apps and tested spring, grails and seam so far. I've also looked aboard java and gave ruby on rails a try too. In future I will be focusing on portlet development which I've gone through already without a complete framework (just hiberna...

Order by children property in Grails

Is it possible to create a criteria that lists all objects sorted by sope property of their children? For example: class Post { User owner } Post.withCriteria { order('owner.registerDate', 'asc') } It fails with message: Error 500: org.hibernate.QueryException: could not resolve property: owner.registerDate of: Post What is ...

Grails: JSONP callback without id and class in JSON file

Hi, I am working on a REST based interface where people get a json file. The client needs to access the file from another Domain. I use jsonp which works so far. My problem is the rendering in Grails. At the moment I use the 'as JSON' to marshalling the object: render "${params.jsoncallback}(${user as JSON})" The Json file getting to...

Hibernate/GORM: collection was not processed by flush()

Hi, I have an integration test in my Grails application that fails when I try to save an entity of type Member invitingMember.save(flush: true) This raises the following exception org.hibernate.AssertionFailure: collection [com.mycompany.facet.Facet.channels] was not processed by flush() at com.mycompany.member.MemberConn...

Searching association table using criteria

I have the following grails domains (example): // a member of the library class LibraryUser { string name } // a book class Book { string title string author } // association which user currently has which book checked out class Checkout { LibraryUser user Book book } How can I retrieve an alphabetically...

Handling `lastUpdated` in a grails domain

I want to use the lastUpdated field of a Grails domain to implement a "what objects have recently changed" view. However my domain has a has-many association which when something is added will cause the lastUpdated value to be updated. E.g.: class Author { string name Date lastUpdated static hasMany = [ books : Book ] } A...

In Grails, how to invoke a controller action from a g:select

I'm using a g:select (actually, a g:currencySelect) in my view. I want a controller action to fire as soon as the user changes the value in the resulting select box. How can I do this? ...

Grails: How do you unit test a command object with a service injected into it

I am trying to test a Controller that has a Command object with data binding. The Command Object has a Service injected into it. But When I try test the command object the injected service method is never found as it is never "injected" Is there a way to mock a service inside a command object? Test method void testLoginPasswordInv...

Re-using a JoinTable in grails

I have two domains that have a many-to-many relationship. Example: class LibraryUser { String name static hasMany = [ checkedoutBooks : Book ] } class Book { String title static hasMany = [ usersWhoCheckedItOut : LibraryUser ] } However I now want to record the time of checkout and store this in the already existing j...

Using groovy metaClass to mock out Shiro SecurityUtils in bootstrap

For further background, see http://grails.markmail.org/message/62w2xpbgneapmhpd I'm trying to mock out the Shiro SecurityUtils.getSubject() method in my BootStrap.groovy. I decided on this approach because the Subject builder in the latest Shiro version isn't available in the current version of the Nimble plugin (which I'm using). I d...

Grails: what are the other alternatives to sitemesh for gsp view layouts?

Sitemesh seems to be an open-source project with minimal activity and small user community. So, I was wondering whether there are (better) alternatives to sitemesh, as a templating layout engine ? And if it is the case, how can one integrate it into a grails application? Thank you, Fabien. ...

how to assert response success in groovy unit testing

Hey i am trying to develop a sample app in groovy on grails...i have an action called login..which doesn't do anything except to render a page called login...I think there is no need to explicitly render any view called login inside the action, as my view name matches the action name. def login = { } As i follow TDD..I want to assert...

How do I increase allocated memory in jvm for Grails commands on IntelliJ IDEA 9 Beta ?

I use Windows Vista , 4GB RAM , Core2 I have tested with this idea.exe.vmoptions : -Xms64m -Xmx512m -XX:MaxPermSize=256m -ea -agentlib:yjpagent=disablej2ee,disablecounts,disablealloc,sessionname=IntelliJIdea90 ...

View Level Security Pattern

Background: The grails application I am developing has a few levels of granular security. First the least granular is at the controller level. Either you can view a specific page or you cannot (I am using the Acegi spring security plugin). The second level of security is in the service layer via an AOP approach. You can either access a c...

Integration Testing w/ Acegi Protected Controllers

In a Grails app, how can I mock an authenticated user so that I can write integration tests for controller actions, which are protected by Acegi? For example, let's say I have a blog application, and the /post/save action is restricted to ROLE_AUTHOR. What might an integration test for this action look like? ...