Quantcast

Grails 1.3.8 - Problem dependency injection happening after command validation

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Grails 1.3.8 - Problem dependency injection happening after command validation

Dave Englert
Hi,

We have tried to upgrade our application from 1.3.7 to 1.3.8 but have
run into a bit of an issue.

Some of our command objects use auto-wired injected services which are
used in some of the validation rules in the constraints, very much
like this example from the Grails 1.3.7 guide:


class LoginCommand {
    LoginService loginService
    String username
    String password

    static constraints = {
        username validator: { val, obj ->
            obj.loginService.canLogin(obj.username, obj.password)
        }
    }
}


However after upgrading to 1.3.8 the loginService is null and we get a
null pointer exception, as dependencies are now injected after the
binding and validation. We have tested this with the example code
above.

We have tried to get the bean and inject it ourself in the username
constraint, but the methods we have found all depend on other
dependencies having already been injected . . .

It would be nice to not have to refactor lots of our code to
accommodate this change.

Any help much appreciated!

Dave

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Loading...