[jboss-cvs] jboss-seam/src/main/org/jboss/seam/core ...
Gavin King
gavin.king at jboss.com
Wed Jul 12 15:59:59 EDT 2006
User: gavin
Date: 06/07/12 15:59:59
Modified: src/main/org/jboss/seam/core Redirect.java Manager.java
Log:
allow more control over conversation propagation across redirects
Revision Changes Path
1.4 +20 -3 jboss-seam/src/main/org/jboss/seam/core/Redirect.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Redirect.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Redirect.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- Redirect.java 24 May 2006 07:04:35 -0000 1.3
+++ Redirect.java 12 Jul 2006 19:59:58 -0000 1.4
@@ -27,6 +27,7 @@
{
private String viewId;
private Map<String, Object> parameters = new HashMap<String, Object>();
+ private boolean conversationPropagationEnabled = true;
/**
* Get the JSF view id to redirect to
@@ -76,12 +77,28 @@
}
/**
+ * Should the conversation be propagated across the redirect?
+ * @return true by default
+ */
+ public boolean isConversationPropagationEnabled()
+ {
+ return conversationPropagationEnabled;
+ }
+
+ /**
+ * Note that conversations are propagated by default
+ */
+ public void setConversationPropagationEnabled(boolean conversationPropagationEnabled)
+ {
+ this.conversationPropagationEnabled = conversationPropagationEnabled;
+ }
+
+ /**
* Perform the redirect
*/
public void execute()
{
- // only include the conv-id if the Seam redirect filter is installed
- Manager.instance().redirect(viewId, parameters, false);
+ Manager.instance().redirect(viewId, parameters, conversationPropagationEnabled);
}
public static Redirect instance()
1.77 +29 -3 jboss-seam/src/main/org/jboss/seam/core/Manager.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Manager.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Manager.java,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -b -r1.76 -r1.77
--- Manager.java 1 Jul 2006 12:38:48 -0000 1.76
+++ Manager.java 12 Jul 2006 19:59:59 -0000 1.77
@@ -44,7 +44,7 @@
*
* @author Gavin King
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.76 $
+ * @version $Revision: 1.77 $
*/
@Scope(ScopeType.EVENT)
@Name("org.jboss.seam.core.manager")
@@ -77,6 +77,8 @@
private boolean nonFacesRequest = true;
+ private boolean controllingRedirect;
+
private int conversationTimeout = 600000; //10 mins
private String conversationIdParameter = "conversationId";
@@ -792,7 +794,7 @@
setLongRunningConversation(true);
}
- public String encodeConversationId(String url) {
+ private String encodeConversationId(String url) {
if ( Seam.isSessionInvalid() )
{
return url;
@@ -891,6 +893,7 @@
beforeRedirect();
}
ExternalContext externalContext = context.getExternalContext();
+ controllingRedirect = true;
try
{
externalContext.redirect( externalContext.encodeActionURL(url) );
@@ -899,10 +902,33 @@
{
throw new RuntimeException("could not redirect to: " + url, ioe);
}
+ finally
+ {
+ controllingRedirect = false;
+ }
context.responseComplete(); //work around MyFaces bug in 1.1.1
}
/**
+ * Called by the Seam Redirect Filter when a redirect is called.
+ * Appends the conversationId parameter if necessary.
+ *
+ * @param url the requested URL
+ * @return the resulting URL with the conversationId appended
+ */
+ public String appendConversationIdFromRedirectFilter(String url)
+ {
+ boolean appendConversationId = !controllingRedirect &&
+ !url.contains("?" + getConversationIdParameter() +"=");
+ if (appendConversationId)
+ {
+ url = encodeConversationId(url);
+ beforeRedirect();
+ }
+ return url;
+ }
+
+ /**
* If a page description is defined, remember the description and
* view id for the current page, to support conversation switching.
*/
More information about the jboss-cvs-commits
mailing list