History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: GRAILS-1826
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Blocker Blocker
Assignee: Graeme Rocher
Reporter: David White
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Grails

Filter 'afterView' closure not called properly

Created: 12/Nov/07 06:43 PM   Updated: 19/Nov/07 08:59 AM
Component/s: Controllers
Affects Version/s: 1.0-RC1
Fix Version/s: 1.0-RC2

Time Tracking:
Not Specified


 Description  « Hide
I was trying to create a filter that would be called in the 'before' and 'afterView' stages of processing and I think I may have found a bug. Basically I wasn't seeing my 'afterView' filter getting called. The filter looks basically like this:
class MyFilters {

    def filters = {
       
        contextSetup(controller: '*', action: '*') {
            before = {
                if (Context.getContext() == null) {
                    Context.createContext(request, response)
                }
            }
            afterView = {
                if (Context.getContext() != null) {
                    Context.destroyContext ()
                }
            }
        }
    }
}

Where Context is my own app specific Java class. I dug into this a bit and found that in the Grails class:

org.codehaus.groovy.grails.plugins.web.filters.FilterToHandlerAdapter , the afterCompletion methos looks like this:

void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object o, Exception e) throws java.lang.Exception {
        if (filterConfig.afterComplete ) {

            String controllerName = controllerName(request)
            String actionName = actionName(request)
            String uri = uri(request)

            if (!accept(controllerName, actionName, uri)) return;
            def callable = filterConfig.afterView.clone()
            callable.delegate = new FilterActionDelegate()
            callable.resolveStrategy = Closure.DELEGATE_FIRST
           
            callable.call (e);
        }
    }

I believe the line:

if (filterConfig.afterComplete) {

should read:

if (filterConfig.afterView) {



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
There are no comments yet on this issue.