in my Grails application , i made a filter on a controller , all working fine except this part :
flash.message = message(code: 'empSeeker.profileExists')
and the error is :
Message:No signature of method: com.MyApp.filters.HRCheckFilters.message() is applicable for argument types: (java.util.LinkedHashMap) values: [[code:empSeeker.profileExists]] Possible solutions: isCase(java.lang.Object)
but if i changed it with flash.message="Any message" it works,
Any reason why it is not working ?
I thought that most things like this that work in a controller also work in filters, but apparently not. In this case there's a workaround that's actually a better approach.
messageworks in a controller because controllers support calling taglibs directly, and if the namespace isgthen you can omit it, so callingmessageorg.messagein a controller both invoke the<g:message>taglib. But all the taglib does is render messages from themessageSourceSpring bean, so you can skip a layer or two of indirection and call that directly.Add this import to your filters class
and this dependency injection
and then you can set the flash message with