Revision: 908
http://stripes.svn.sourceforge.net/stripes/?rev=908&view=rev
Author: bengunter
Date: 2008-05-15 13:10:48 -0700 (Thu, 15 May 2008)
Log Message:
-----------
Fixed STS-565. Beans that were flashed from the previous request and were
intended to handle the ensuing request did not receive the correct
ActionBeanContext. That is fixed now.
Modified Paths:
--------------
trunk/stripes/src/net/sourceforge/stripes/controller/AnnotatedClassActionResolver.java
trunk/stripes/src/net/sourceforge/stripes/controller/NameBasedActionResolver.java
Modified:
trunk/stripes/src/net/sourceforge/stripes/controller/AnnotatedClassActionResolver.java
===================================================================
---
trunk/stripes/src/net/sourceforge/stripes/controller/AnnotatedClassActionResolver.java
2008-05-15 16:13:22 UTC (rev 907)
+++
trunk/stripes/src/net/sourceforge/stripes/controller/AnnotatedClassActionResolver.java
2008-05-15 20:10:48 UTC (rev 908)
@@ -336,25 +336,16 @@
bean = makeNewActionBean(beanClass, context);
request.getSession().setAttribute(bindingPath, bean);
}
-
- bean.setContext(context);
}
else {
bean = (ActionBean) request.getAttribute(bindingPath);
if (bean == null) {
bean = makeNewActionBean(beanClass, context);
- bean.setContext(context);
request.setAttribute(bindingPath, bean);
}
- else {
- if (bean.getContext() == null) {
- bean.setContext(context);
- }
- else {
- bean.getContext().setRequest(request);
- }
- }
}
+
+ setActionBeanContext(bean, context);
}
catch (Exception e) {
StripesServletException sse = new StripesServletException(
@@ -369,6 +360,29 @@
}
/**
+ * Calls [EMAIL PROTECTED] ActionBean#setContext(ActionBeanContext)} with
the given [EMAIL PROTECTED] context} only if
+ * necessary. Subclasses should use this method instead of setting the
context directly because
+ * it can be somewhat tricky to determine when it needs to be done.
+ *
+ * @param bean The bean whose context may need to be set.
+ * @param context The context to pass to the bean if necessary.
+ */
+ protected void setActionBeanContext(ActionBean bean, ActionBeanContext
context) {
+ ActionBeanContext abcFromBean = bean.getContext();
+ if (abcFromBean == null) {
+ bean.setContext(context);
+ }
+ else {
+ StripesRequestWrapper wrapperFromBean = StripesRequestWrapper
+ .findStripesWrapper(abcFromBean.getRequest());
+ StripesRequestWrapper wrapperFromRequest = StripesRequestWrapper
+ .findStripesWrapper(context.getRequest());
+ if (wrapperFromBean != wrapperFromRequest)
+ bean.setContext(context);
+ }
+ }
+
+ /**
* Since many down stream parts of Stripes rely on the ActionBean properly
returning the
* context it is given, we'll just test it up front. Called after the bean
is instantiated.
*
Modified:
trunk/stripes/src/net/sourceforge/stripes/controller/NameBasedActionResolver.java
===================================================================
---
trunk/stripes/src/net/sourceforge/stripes/controller/NameBasedActionResolver.java
2008-05-15 16:13:22 UTC (rev 907)
+++
trunk/stripes/src/net/sourceforge/stripes/controller/NameBasedActionResolver.java
2008-05-15 20:10:48 UTC (rev 908)
@@ -247,9 +247,8 @@
catch (StripesServletException sse) {
ActionBean bean = handleActionBeanNotFound(context, urlBinding);
if (bean != null) {
- bean.setContext(context);
+ setActionBeanContext(bean, context);
assertGetContextWorks(bean);
-
return bean;
}
else {
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