Revision: 921
http://stripes.svn.sourceforge.net/stripes/?rev=921&view=rev
Author: bengunter
Date: 2008-05-21 06:51:14 -0700 (Wed, 21 May 2008)
Log Message:
-----------
Improved fix for STS-571. Forward to the error page instead of
redirecting/flashing because when you flash the same bean you're redirecting
to, the validation errors are lost. (It was decided this is correct behavior,
and it just doesn't work for what I was doing before.)
Modified Paths:
--------------
trunk/stripes/src/net/sourceforge/stripes/exception/DefaultExceptionHandler.java
Modified:
trunk/stripes/src/net/sourceforge/stripes/exception/DefaultExceptionHandler.java
===================================================================
---
trunk/stripes/src/net/sourceforge/stripes/exception/DefaultExceptionHandler.java
2008-05-21 13:42:36 UTC (rev 920)
+++
trunk/stripes/src/net/sourceforge/stripes/exception/DefaultExceptionHandler.java
2008-05-21 13:51:14 UTC (rev 921)
@@ -32,7 +32,7 @@
import net.sourceforge.stripes.action.ActionBean;
import net.sourceforge.stripes.action.ActionBeanContext;
import net.sourceforge.stripes.action.FileBean;
-import net.sourceforge.stripes.action.RedirectResolution;
+import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.config.Configuration;
import net.sourceforge.stripes.controller.DispatcherHelper;
@@ -203,20 +203,31 @@
* this method is unable for any other reason to forward to
the error page
*/
protected Resolution handle(FileUploadLimitExceededException exception,
- HttpServletRequest request, HttpServletResponse response) throws
FileUploadLimitExceededException {
+ HttpServletRequest request, HttpServletResponse response)
+ throws FileUploadLimitExceededException {
// Get the path to which we will forward to display the message
final String path = getFileUploadExceededExceptionPath(request);
if (path == null)
throw exception;
- // Create the ActionBean and ActionBeanContext
+ final StripesRequestWrapper wrapper;
final ActionBeanContext context;
final ActionBean actionBean;
try {
- context =
configuration.getActionBeanContextFactory().getContextInstance(request,
+ // Create a new request wrapper, avoiding the pitfalls of multipart
+ wrapper = new StripesRequestWrapper(request) {
+ @Override
+ protected void constructMultipartWrapper(HttpServletRequest
request)
+ throws StripesServletException {
+
setLocale(configuration.getLocalePicker().pickLocale(request));
+ }
+ };
+
+ // Create the ActionBean and ActionBeanContext
+ context =
configuration.getActionBeanContextFactory().getContextInstance(wrapper,
response);
actionBean =
configuration.getActionResolver().getActionBean(context);
- request.setAttribute(StripesConstants.REQ_ATTR_ACTION_BEAN,
actionBean);
+ wrapper.setAttribute(StripesConstants.REQ_ATTR_ACTION_BEAN,
actionBean);
}
catch (ServletException e) {
log.error(e);
@@ -262,24 +273,14 @@
exectx.setActionBeanContext(context);
DispatcherHelper.fillInValidationErrors(exectx);
- // Redirect back to referer
- return new RedirectResolution(path) {
+ // Forward back to referer, using the wrapped request
+ return new ForwardResolution(path) {
@Override
public void execute(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
- // Create a new request wrapper, avoiding the pitfalls of
multipart
- StripesRequestWrapper wrapper = new
StripesRequestWrapper(request) {
- @Override
- protected void
constructMultipartWrapper(HttpServletRequest request)
- throws StripesServletException {
-
setLocale(configuration.getLocalePicker().pickLocale(request));
- }
- };
-
- // Pass wrapper to superclass
super.execute(wrapper, response);
}
- }.flash(actionBean);
+ };
}
/**
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development