You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by iv...@apache.org on 2013/03/23 22:25:59 UTC
[2/2] git commit: when handling a stale page attempt to reuse its
conversation - because we most likely will render it
when handling a stale page attempt to reuse its conversation - because we most likely will render it
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/72dde905
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/72dde905
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/72dde905
Branch: refs/heads/master
Commit: 72dde905ca19b5872d411c50fc23037653bb8834
Parents: feb3bd6
Author: Igor Vaynberg <ig...@gmail.com>
Authored: Sat Mar 23 14:25:50 2013 -0700
Committer: Igor Vaynberg <ig...@gmail.com>
Committed: Sat Mar 23 14:25:50 2013 -0700
----------------------------------------------------------------------
.../apache/wicket/cdi/ConversationPropagator.java | 28 +++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/72dde905/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationPropagator.java
----------------------------------------------------------------------
diff --git a/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationPropagator.java b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationPropagator.java
index afcfc49..1d8410d 100644
--- a/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationPropagator.java
+++ b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ConversationPropagator.java
@@ -27,9 +27,11 @@ import org.apache.wicket.Page;
import org.apache.wicket.core.request.handler.BufferedResponseRequestHandler;
import org.apache.wicket.core.request.handler.IPageClassRequestHandler;
import org.apache.wicket.core.request.handler.IPageRequestHandler;
+import org.apache.wicket.core.request.mapper.StalePageException;
import org.apache.wicket.request.IRequestHandler;
import org.apache.wicket.request.IRequestHandlerDelegate;
import org.apache.wicket.request.Url;
+import org.apache.wicket.request.component.IRequestablePage;
import org.apache.wicket.request.cycle.AbstractRequestCycleListener;
import org.apache.wicket.request.cycle.IRequestCycleListener;
import org.apache.wicket.request.cycle.RequestCycle;
@@ -103,6 +105,7 @@ public class ConversationPropagator extends AbstractRequestCycleListener
: null;
}
+ @Override
public void onRequestHandlerResolved(RequestCycle cycle, IRequestHandler handler)
{
String cid = cycle.getRequest().getRequestParameters().getParameterValue(CID).toString();
@@ -126,6 +129,30 @@ public class ConversationPropagator extends AbstractRequestCycleListener
@Override
public IRequestHandler onException(RequestCycle cycle, Exception ex)
{
+ // if we are handling a stale page exception then use its conversation since we are most
+ // likely about to rerender it.
+
+ if (ex instanceof StalePageException)
+ {
+ IRequestablePage requestable = ((StalePageException)ex).getPage();
+ if (requestable instanceof Page)
+ {
+ String cid = container.getConversationMarker((Page)requestable);
+ if (cid != null)
+ {
+ try
+ {
+ activateConversationIfNeeded(cycle, null, cid);
+ return null;
+ }
+ catch (ConversationExpiredException e)
+ {
+ // ignore, we will start a new one below
+ }
+ }
+ }
+ }
+
activateConversationIfNeeded(cycle, null, null);
return null;
}
@@ -188,6 +215,7 @@ public class ConversationPropagator extends AbstractRequestCycleListener
}
}
+ @Override
public void onRequestHandlerScheduled(RequestCycle cycle, IRequestHandler handler)
{
Conversation conversation = getConversation(cycle);