Skip to content

Commit ee79ea7

Browse files
author
pledbrook
committed
Flash scope is now initialised in the GrailsWebRequestFilter, before
the Grails filters are invoked. This means that the 'flash' object can now be used from within 'before' filters. git-svn-id: https://svn.codehaus.org/grails/trunk@6482 1cfb16fd-6d17-0410-8ff1-b7e8e1e2867d
1 parent 88f3c4d commit ee79ea7

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package org.codehaus.groovy.grails.web.servlet.mvc;
1717

1818
import org.codehaus.groovy.grails.web.servlet.GrailsApplicationAttributes;
19+
import org.codehaus.groovy.grails.web.servlet.FlashScope;
1920
import org.springframework.context.ApplicationContext;
2021
import org.springframework.context.i18n.LocaleContextHolder;
2122
import org.springframework.web.context.request.RequestContextHolder;
@@ -55,6 +56,15 @@ protected void doFilterInternal(
5556
}
5657
try {
5758
request.setAttribute(GrailsApplicationAttributes.WEB_REQUEST, webRequest);
59+
60+
// Set the flash scope instance to its next state. We do
61+
// this here so that the flash is available from Grails
62+
// filters in a valid state.
63+
FlashScope fs = webRequest.getAttributes().getFlashScope(request);
64+
fs.next();
65+
66+
// Pass control on to the next filter (or the servlet if
67+
// there are no more filters in the chain).
5868
filterChain.doFilter(request, response);
5969
}
6070
finally {

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,7 @@ public ModelAndView handleURI(String uri, GrailsWebRequest webRequest, Map param
217217
throw new NoClosurePropertyForURIException("Could not find closure property for URI [" + uri + "] for controller [" + controllerClass.getFullName() + "]!");
218218
}
219219

220-
// set the flash scope instance to its next state and set on controller
221-
FlashScope fs = this.grailsAttributes.getFlashScope(request);
222-
fs.next();
223-
224-
// Step 4b: Set grails attributes in request scope
220+
// Step 4: Set grails attributes in request scope
225221
request.setAttribute(GrailsApplicationAttributes.REQUEST_SCOPE_ID,this.grailsAttributes);
226222

227223
// Step 5: get the view name for this URI.

0 commit comments

Comments
 (0)