grails

Using ContextLoaderListener to attach parent ApplicationContext to Grails ApplicationContext does not work in Integration Tests

Using ContextLoaderListener to attach parent ApplicationContext to Grails ApplicationContext does not work in Integration Tests To make our grails application work with the rest of our existing spring application, we followed the advice in http://grails.1312388.n4.nabble.com/Grails-and-existing-Spring-web-app-integration-issues-td133936...

Grails/GORM Legacy DB One-to-Many mappedBy issue

I have a legacy DB with rather simple structure. I have "rolls" that contain "rollTotals". Roll has a primary key of "rollID" and RollTotals have a composite key on "rollID" and "category". So in Grails, I have: class Roll { Integer id ... static hasMany = [ rollTotals: RollTotal ] static mapping = { table('roll...

getting the url in the case of an auth failure...

In grails acegi plugin, you can specify the authenticationFailureUrl property in SecurityConfig. Is there a way to get the url that caused the auth failure in the scope of the authenticationFailureUrl? This is not as simple as just getting the request or looking on the params. If there is an auth failure, you get redirected to the a...

Forcing https in Grails

Hi, in a struts application, I have a filter that forces certain pages to be accessed only over https via redirection. I'm thinking in porting it to grails so my question is: In the this environment, is there a "grails" way to implement such filter or is it similar/the same as I did ? Thanks ...

Load snippet of html in controller

I would like to have a snippet html loaded in the action method of a controller. Is there a way to do this? What I want to accomplish is actually have the Controller action use json as the format to return my response (with error codes and other information) and include a snippet of html loaded from a template file as one part of the js...

Does HTML need to be encoded when passed back in JSON?

When passing HTML back through a response in JSON format, does it need to get encoded? ...

Grails finding parent by the many side

Hi, My problem should be obvious, but I just don't see the light right now :-( I have two domainclasses like this: class Parent { String name static hasMany = [children: Child] } class Child { String name } Now I should be able to find the Parent of a child by using the dynamic finder of the Parent like: Parent.findByChild...

getting random records in many-to-many relationship with namedQuery

I have a many-to-many relationship between two objects with a join table. I need to be able to select 5 random children based on Parent and date, excluding some children records. I am stuck. Any ideas? Parent { static hasMany = [children: Child] } Child { Date dob static belongsTo = [Parent] static ha...

When should hasMany be used for N:1 relationships in grails domain classes?

In grails, I can implement an N:1 relationship like this: class Parent { hasMany = [children:Child] } class Child { belongsTo = [parent:Parent] } Now (if addTo and removeFrom is always properly used) I can get a Parent's children via parent.children. But I can also do it without hasMany: class Parent { } class Child { belongsTo = ...

Grails Indexed Properties with No Real Index

Grails 1.3.1 I am using a jQuery library that sends a serialized parameter map to the server and it is formatted like so.... item[]=1&item[]=2&item[]=3 In my controller, when I do println params, it comes out... [item[]: [1, 2, 3]] I can't seem to get this data out of params in my controller, however. What am I missing? ...

Querying on property of a hasMany relationship

I have the following association in a domain I'm working on (not actually pirates unfortunately). A ship has many pirates. I want to be able to find all ships that have a captain and do not have any land lubbers on the crew. class Pirate { String name Rank rank enum Rank { CAPTAIN, DECK_HAND, LAND_LUBBER } } cl...

Grails - access only for object's owner

Hi! I'm still working on my first Grails application. This time, my problem is to limit access to some actions for particular users. Assume users add some object, e.g. books. I would like to give access to edit a book only to admin and the user that added the book. I'm currently using Acegi plugin. I know there is newer version of that...

Lazy fetching of objects using FindAllBy , for the first time

Hello, When I use criteria queries, the result contains array list of lazy initialized objects. that is, the list has values with handler org.codehaus.groovy.grails.orm.hibernate.proxy.GroovyAwareJavassistLazyInitializer. This prevent me from doing any array operation (minus, remove etc) in it. When I use, GORM meth...

grails findAll tag

How to use "SELECT id, name, part, description FROM user " in grails findAll tag. I tried User.findAll("SELECT id, name, part, description FROM user") instead using User.findAll("FROM user") But shows errors . can anyone suggest me the tag thanks, sri.. ...

using service account as ldapManagerDN

I am using a "service account" for ldapManagerDN to do LDAP authentication for my Grails web app, and I have found the following problem: if the service account is set up (in Active Directory) to be able to log on to any machine, it is working fine, but if the service account is set up to be limited log on to just couple of machines, the...

Grails: How do I make my page load a filter when the page loads??

On index.gsp I have this to redirect it to list.gsp so I'm imagining is should be something like this: ${response.sendRedirect("entry/list")} My filter is just one textField and two datePickers with drop down boxes (DD-MMM-YYYY) and they should be by default filtered from today's date to infinity. So it should show me only the events ...

Grails Scaffolding Default Date

Hello, I'm using Grails scaffolding and would like to make a change in the default date during a create. Currently dates default to today's date. How would one default it to blank or no date? Thanks, Steve ...

What is the best Java RESTful framework for a very simple backend server?

I need to develop a very thin shim for hadoop to be used together with Rails/Sinatra application. I'm a .Net developer and have a lot experience with Ruby. So what is the best framework to choose giving the fact it is needed for a very small project and it should provide RESTful web services. I looked at Grails and it seems to be very r...

sorting problem with multiple joins

I have a problem getting sorting to work with multiple joined tables. For example: class Account { static hasMany = [subscriptions: Subscription] static mapping = { subscriptions fetch: 'join' subscriptions sort: 'magazine' } } class Subscription { static belongsTo = [account:Account, magazine: Magazine] static m...

Grails: How to create a clear button?

Hello I have created a filter for my list. In a template named _search.gsp And I need a clear button that clears out all the fields in the filter. I have one textField named proyectoRutaN And four datePickers named fechaCambioD , fechaCambioH , lastUpdatedD, and lastUpdatedH Any help would be greatly appreciated! Thanks! -Fernando ...