Skip to content

Commit efa3840

Browse files
author
graeme
committed
fix for GRAILS-1517
git-svn-id: https://svn.codehaus.org/grails/trunk@5262 1cfb16fd-6d17-0410-8ff1-b7e8e1e2867d
1 parent 004e510 commit efa3840

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/web/org/codehaus/groovy/grails/web/servlet/mvc/SimpleGrailsControllerHelper.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,21 @@ public ModelAndView handleURI(String uri, GrailsWebRequest webRequest, Map param
227227
// Step 5: get the view name for this URI.
228228
String viewName = controllerClass.getViewByURI(uri);
229229

230+
boolean executeAction = invokeBeforeInterceptor(controller, controllerClass);
231+
// if the interceptor returned false don't execute the action
232+
if(!executeAction)
233+
return null;
234+
235+
ModelAndView mv;
230236
if(controllerClass.isFlowAction(actionName)) {
231-
return executeFlow(webRequest,request, response);
237+
mv = executeFlow(webRequest,request, response);
232238
}
233239
else {
234-
return executeAction(controller, controllerClass, viewName, request, response, params);
240+
mv = executeAction(controller, controllerClass, viewName, request, response, params);
235241
}
236242

243+
boolean returnModelAndView = invokeAfterInterceptor(controllerClass, controller, mv);
244+
return returnModelAndView ? mv : null;
237245
}
238246

239247
/**
@@ -248,6 +256,7 @@ protected ModelAndView executeFlow(GrailsWebRequest webRequest, final HttpServle
248256
final Thread currentThread = Thread.currentThread();
249257
ClassLoader cl = currentThread.getContextClassLoader();
250258
try {
259+
251260
currentThread.setContextClassLoader(application.getClassLoader());
252261

253262
FlowExecutorArgumentHandler argumentHandler = new GrailsConventionsFlowExecutorArgumentHandler(webRequest);
@@ -268,6 +277,8 @@ public String getDispatcherPath() {
268277
return super.getDispatcherPath();
269278
}
270279
};
280+
281+
271282
ResponseInstruction responseInstruction = createRequestHandler(argumentHandler).handleFlowRequest(externalContext);
272283

273284
return toModelAndView(responseInstruction, externalContext, argumentHandler);
@@ -366,12 +377,6 @@ protected ModelAndView executeAction(GroovyObject controller, GrailsControllerCl
366377
// Step 5a: Check if there is a before interceptor if there is execute it
367378
ClassLoader cl = Thread.currentThread().getContextClassLoader();
368379
try {
369-
Thread.currentThread().setContextClassLoader(application.getClassLoader());
370-
boolean executeAction = invokeBeforeInterceptor(controller, controllerClass);
371-
// if the interceptor returned false don't execute the action
372-
if(!executeAction)
373-
return null;
374-
375380
// Step 6: get closure from closure property
376381
Closure action;
377382
try {
@@ -386,7 +391,6 @@ protected ModelAndView executeAction(GroovyObject controller, GrailsControllerCl
386391
if(LOG.isDebugEnabled()) {
387392
LOG.debug("Response has been redirected, returning null model and view");
388393
}
389-
invokeAfterInterceptor(controllerClass, controller, null);
390394
return null;
391395
}
392396
else {
@@ -398,8 +402,7 @@ protected ModelAndView executeAction(GroovyObject controller, GrailsControllerCl
398402
if(LOG.isDebugEnabled()) {
399403
LOG.debug("Action ["+actionName+"] handled, created Spring model and view ["+mv+"]");
400404
}
401-
boolean returnModelAndView = invokeAfterInterceptor(controllerClass, controller, mv);
402-
return returnModelAndView ? mv : null;
405+
return mv;
403406
}
404407

405408
}

0 commit comments

Comments
 (0)