Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to call service from controller in grails

I have a service class and i am trying to call the method of the service in my controller as below.

class LogListController {

def ListLogDetails = { 
    println "We are inside List log Details-->"+params
    def logListHelperService
    logListHelperService.getFilePath(params)
}}

Exception Message: Cannot invoke method getFilePath() on null object

what is my mistake there..

like image 423
laxmi Avatar asked Dec 21 '22 13:12

laxmi


1 Answers

def logListHelperService

must be declared outside of the ListLogDetails definition

def logListHelperService
def ListLogDetails = { 
    println "We are inside List log Details-->"+params
    logListHelperService.getFilePath(params)
}

should work

like image 53
mjspier Avatar answered Dec 27 '22 21:12

mjspier