Author: cpopetz
Date: 2009-03-10 09:39:26 -0400 (Tue, 10 Mar 2009)
New Revision: 10141
Added:
trunk/src/wicket/org/jboss/seam/wicket/SeamEnforceConversationListener.java
Removed:
trunk/src/wicket/org/jboss/seam/wicket/SeamComponentInstantiationListener.java
Modified:
trunk/src/wicket/org/jboss/seam/wicket/WicketComponent.java
trunk/src/wicket/org/jboss/seam/wicket/ioc/ConversationInterceptor.java
Log:
JBSEAM-3724: Wicket NoConversationPage is often ignored
Deleted: trunk/src/wicket/org/jboss/seam/wicket/SeamComponentInstantiationListener.java
===================================================================
---
trunk/src/wicket/org/jboss/seam/wicket/SeamComponentInstantiationListener.java 2009-03-10
13:39:03 UTC (rev 10140)
+++
trunk/src/wicket/org/jboss/seam/wicket/SeamComponentInstantiationListener.java 2009-03-10
13:39:26 UTC (rev 10141)
@@ -1,38 +0,0 @@
-package org.jboss.seam.wicket;
-
-import org.apache.wicket.AbortException;
-import org.apache.wicket.Component;
-import org.apache.wicket.Page;
-import org.apache.wicket.RequestCycle;
-import org.apache.wicket.application.IComponentInstantiationListener;
-import org.jboss.seam.core.Manager;
-import org.jboss.seam.international.StatusMessage;
-import org.jboss.seam.international.StatusMessages;
-
-public class SeamComponentInstantiationListener implements
IComponentInstantiationListener
-{
-
- public void onInstantiation(Component component)
- {
- if (!Manager.instance().isLongRunningConversation())
- {
- WicketComponent<?> wicketComponent =
WicketComponent.getInstance(component.getClass());
- if (wicketComponent != null)
- {
- Class<? extends Page> noConversationPage =
wicketComponent.getNoConversationPage();
- if (noConversationPage != null)
- {
- final RequestCycle cycle = RequestCycle.get();
- StatusMessages.instance().addFromResourceBundleOrDefault(
- StatusMessage.Severity.WARN,
- "org.jboss.seam.NoConversation",
- "The conversation ended or timed"
- );
- cycle.redirectTo(component.getPageFactory().newPage(noConversationPage));
- throw new AbortException();
- }
- }
- }
- }
-
-}
Copied: trunk/src/wicket/org/jboss/seam/wicket/SeamEnforceConversationListener.java (from
rev 9819, trunk/src/wicket/org/jboss/seam/wicket/SeamComponentInstantiationListener.java)
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/SeamEnforceConversationListener.java
(rev 0)
+++ trunk/src/wicket/org/jboss/seam/wicket/SeamEnforceConversationListener.java 2009-03-10
13:39:26 UTC (rev 10141)
@@ -0,0 +1,41 @@
+package org.jboss.seam.wicket;
+
+import org.apache.wicket.AbortException;
+import org.apache.wicket.Component;
+import org.apache.wicket.Page;
+import org.apache.wicket.RequestCycle;
+import org.apache.wicket.application.IComponentOnBeforeRenderListener;
+import org.jboss.seam.core.Manager;
+import org.jboss.seam.international.StatusMessage;
+import org.jboss.seam.international.StatusMessages;
+
+/**
+ * A listener registered by SeamWebApplication which ensures that a long-running
conversation exists when a page
+ * annotated with NoConversationPage is rendered
+ *
+ */
+public class SeamEnforceConversationListener implements IComponentOnBeforeRenderListener
+{
+ public void onBeforeRender(Component component)
+ {
+ if (!Manager.instance().isLongRunningConversation())
+ {
+ WicketComponent<?> wicketComponent =
WicketComponent.getInstance(component.getClass());
+ if (wicketComponent != null)
+ {
+ Class<? extends Page> noConversationPage =
wicketComponent.getNoConversationPage();
+ if (noConversationPage != null)
+ {
+ final RequestCycle cycle = RequestCycle.get();
+ StatusMessages.instance().addFromResourceBundleOrDefault(
+ StatusMessage.Severity.WARN,
+ "org.jboss.seam.NoConversation",
+ "The conversation ended or timed"
+ );
+ cycle.redirectTo(component.getPageFactory().newPage(noConversationPage));
+ throw new AbortException();
+ }
+ }
+ }
+ }
+}
Property changes on:
trunk/src/wicket/org/jboss/seam/wicket/SeamEnforceConversationListener.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:mergeinfo
+
Modified: trunk/src/wicket/org/jboss/seam/wicket/WicketComponent.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/WicketComponent.java 2009-03-10 13:39:03 UTC
(rev 10140)
+++ trunk/src/wicket/org/jboss/seam/wicket/WicketComponent.java 2009-03-10 13:39:26 UTC
(rev 10141)
@@ -21,6 +21,7 @@
import org.jboss.seam.RequiredException;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Begin;
+import org.jboss.seam.annotations.Conversational;
import org.jboss.seam.annotations.End;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
@@ -367,7 +368,8 @@
method.isAnnotationPresent(End.class) ||
method.isAnnotationPresent(StartTask.class) ||
method.isAnnotationPresent(BeginTask.class) ||
- method.isAnnotationPresent(EndTask.class) )
+ method.isAnnotationPresent(EndTask.class) ||
+ method.isAnnotationPresent(Conversational.class))
{
conversationManagementMembers.add(method);
}
Modified: trunk/src/wicket/org/jboss/seam/wicket/ioc/ConversationInterceptor.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/ioc/ConversationInterceptor.java 2009-03-10
13:39:03 UTC (rev 10140)
+++ trunk/src/wicket/org/jboss/seam/wicket/ioc/ConversationInterceptor.java 2009-03-10
13:39:26 UTC (rev 10141)
@@ -3,8 +3,14 @@
import java.lang.reflect.Method;
import java.util.Arrays;
+import org.apache.wicket.AbortException;
+import org.apache.wicket.Page;
+import org.apache.wicket.RequestCycle;
+import org.apache.wicket.Session;
+import org.jboss.seam.NoConversationException;
import org.jboss.seam.annotations.ApplicationException;
import org.jboss.seam.annotations.Begin;
+import org.jboss.seam.annotations.Conversational;
import org.jboss.seam.annotations.End;
import org.jboss.seam.annotations.FlushModeType;
import org.jboss.seam.annotations.bpm.BeginTask;
@@ -15,6 +21,8 @@
import org.jboss.seam.core.ConversationPropagation;
import org.jboss.seam.core.Interpolator;
import org.jboss.seam.core.Manager;
+import org.jboss.seam.international.StatusMessage;
+import org.jboss.seam.international.StatusMessages;
import org.jboss.seam.navigation.ConversationIdParameter;
import org.jboss.seam.navigation.Pages;
import org.jboss.seam.pageflow.Pageflow;
@@ -32,11 +40,7 @@
throw new IllegalStateException("begin method invoked from a
long-running conversation, try using @Begin(join=true) on method: " +
invocationContext.getMember().getName());
}
-
- /*if ( redirectToExistingConversation(invocationContext.getMethod()) )
- {
- return null;
- }*/
+ checkForConversation(invocationContext);
}
}
@@ -134,7 +138,32 @@
invocationContext.getAccessibleObject().isAnnotationPresent(StartTask.class)
);
}
+
+ private void checkForConversation(InvocationContext<T> invocationContext)
+ {
+ if (!Manager.instance().isLongRunningConversation() &&
+
invocationContext.getAccessibleObject().isAnnotationPresent(Conversational.class))
+ {
+ Class<? extends Page> noConversationPage =
invocationContext.getComponent().getNoConversationPage();
+ if (noConversationPage != null)
+ {
+ final RequestCycle cycle = RequestCycle.get();
+ StatusMessages.instance().addFromResourceBundleOrDefault(
+ StatusMessage.Severity.WARN,
+ "org.jboss.seam.NoConversation",
+ "The conversation ended or timed"
+ );
+
cycle.redirectTo(Session.get().getPageFactory().newPage(noConversationPage));
+ throw new AbortException();
+ }
+ else
+ {
+ throw new NoConversationException( "no long-running conversation for
@Conversational wicket component: " +
invocationContext.getComponent().getClass().getName());
+ }
+ }
+ }
+
@SuppressWarnings("deprecation")
private void beginConversationIfNecessary(InvocationContext invocationContext, Object
result)
{
Show replies by date