I have a command class which needs to call a service.
import org.codehaus.groovy.grails.commons.ApplicationHolder as AH
class FilterVisitCommand {
def accessRightsService = AH.application.mainContext.accessRightsService
def customerService = AH.application.mainContext.customerService
...
}
This kind service definition via application holder is working however is depracated. Is there another way to let the service be injected? Only "def accessRightsService" does not work for the command class.
If you are injecting a service into a command object for validation, you may need to reference the service via the command object.
class FilterVisitCommand {
def accessRightsService
static constraints = {
foo(validator: { foo, cmd ->
cmd.accessRightsService.bar()
})
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With