geofflane / grails-constraints

Custom constraints plugin for Grails applications
Apache License 2.0
35 stars 11 forks source link

Dependency injection not being auto-wired #1

Closed bwoodcox closed 14 years ago

bwoodcox commented 14 years ago

In the plugin documentation, it indicates that dependency injection of services is supported. The following code doesn't seem to inject the armService into the constraint.

package com.vitalsmarts.ema.constraint

class OrderFoundConstraint { def armService

static defaultMessageCode = "default.order.not.found.error" static failureCode = "order.not.found.error"

def validate = {identifier -> armService.basicOrderInfo(identifier) ? true : false } }

The exception is a null pointer because armService is null. Any suggestions oralternatives?

geofflane commented 14 years ago

Definitely an issue. I thought this was working but apparently it's not any longer.I need to change the plugin to register the custom Constraints as Spring beans and then to load them via Spring whenever they are instantiated. Sounds easy... but I've not gotten it to work yet.

Thanks for the report

geofflane commented 14 years ago

This is fixed with the 0.5 release.