I’m trying to render a .GSP view inside the view folder from my filter. The following code show that:
def filters = {
all(controller:'*', action:'*') {
afterView = { Exception e ->
if (controllerName) {
//some code here
if (annotation!=null) {
switch(response.format){
case 'all':
if(!response.containsHeader("AC_MSG")|| !response.containsHeader("AC_STATUS")){
render(view: "/internalerror", model: [controller: controllerName,action:currentAction,
message:"Response doesn't contain required headers AC_MSG or AC_STATUS. Either add the required headers or use json format.",
example:"Add the following response headers: AC_MSG:response message , AC_STATUS: false or true"
])
return false
}
break
default:
render status: 406
break
}
}
}
}
}
}
The problem is that this page didn’t get rendered even the code is executed. The page is on the view directory directly. What I did wrong?
Thanks,
I don’t think a filter can render a gsp, but controllers can.
A perfect example of what you want to do is available in the docs: filters
Basically you create an action inside a controller that renders the page, and the filter just redirects to the action.
case ‘all’: