[jboss-cvs] jboss-seam/src/main/org/jboss/seam/core ...
Gavin King
gavin.king at jboss.com
Thu Mar 8 19:17:51 EST 2007
User: gavin
Date: 07/03/08 19:17:51
Modified: src/main/org/jboss/seam/core Manager.java Pages.java
Log:
fix some bugs with natural conversation ids
Revision Changes Path
1.158 +34 -25 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.157
retrieving revision 1.158
diff -u -b -r1.157 -r1.158
--- Manager.java 8 Mar 2007 17:16:16 -0000 1.157
+++ Manager.java 9 Mar 2007 00:17:51 -0000 1.158
@@ -45,7 +45,7 @@
*
* @author Gavin King
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.157 $
+ * @version $Revision: 1.158 $
*/
@Scope(ScopeType.EVENT)
@Name("org.jboss.seam.core.manager")
@@ -437,8 +437,9 @@
if ( facesContext!=null && facesContext.getViewRoot()!=null )
{
Page page = Pages.instance().getPage( facesContext.getViewRoot().getViewId() );
- storedConversationId = page.getConversationIdParameter().getRequestConversationId();
- isLongRunningConversation = false; //TODO: think about this further...
+ storedConversationId = page.getConversationIdParameter().getRequestConversationId(parameters);
+ //isLongRunningConversation = false; //TODO: think about this further...
+ isLongRunningConversation = "true".equals( getRequestParameterValue(parameters, conversationIsLongRunningParameter) );
}
//Next, try to get the conversation id from the globally defined request parameter
@@ -620,7 +621,7 @@
* @param parameters the request parameters
* @return the conversation id
*/
- private String getRequestParameterValue(Map parameters, String parameterName) {
+ public static String getRequestParameterValue(Map parameters, String parameterName) {
Object object = parameters.get(parameterName);
if (object==null)
{
@@ -669,7 +670,7 @@
if ( facesContext!=null && facesContext.getViewRoot()!=null )
{
Page page = Pages.instance().getPage( facesContext.getViewRoot().getViewId() );
- return page.getConversationIdParameter().getInitialConversationId();
+ return page.getConversationIdParameter().getInitialConversationId( facesContext.getExternalContext().getRequestParameterMap() );
}
else
{
@@ -756,7 +757,9 @@
// (1) a cache
// (2) so we can unlock() it after destruction of the session context
private ConversationEntry currentConversationEntry;
- public ConversationEntry getCurrentConversationEntry() {
+
+ public ConversationEntry getCurrentConversationEntry()
+ {
if (currentConversationEntry==null)
{
currentConversationEntry = ConversationEntries.instance().getConversationEntry( getCurrentConversationId() );
@@ -811,11 +814,6 @@
this.conversationTimeout = conversationTimeout;
}
- public void beforeRedirect()
- {
- beforeRedirect(null);
- }
-
/**
* Temporarily promote a temporary conversation to
* a long running conversation for the duration of
@@ -823,7 +821,7 @@
* conversation will be demoted back to a temporary
* conversation.
*/
- public void beforeRedirect(String viewId)
+ public void beforeRedirect()
{
//DONT BREAK, icefaces uses this
if (!destroyBeforeRedirect)
@@ -837,26 +835,37 @@
ce.setRemoveAfterRedirect( !isLongRunningConversation() );
setLongRunningConversation(true);
}
+ }
- FacesContext ctx = FacesContext.getCurrentInstance();
-
- if (viewId != null && ctx != null && ctx.getViewRoot() != null)
+ /**
+ * Temporarily promote a temporary conversation to
+ * a long running conversation for the duration of
+ * a browser redirect. After the redirect, the
+ * conversation will be demoted back to a temporary
+ * conversation. Handle any changes to the conversation
+ * id, due to propagation via natural id.
+ */
+ public void beforeRedirect(String viewId)
{
- Page source = Pages.instance().getPage(ctx.getViewRoot().getViewId());
- Page target = Pages.instance().getPage(viewId);
+ beforeRedirect();
- ConversationIdParameter sp = source.getConversationIdParameter();
- ConversationIdParameter tp = target.getConversationIdParameter();
-
- if ((sp.getName() == null && tp.getName() != null) ||
- (sp.getName() != null && tp.getName() == null) ||
- (sp.getName() != null && !sp.getName().equals(tp.getName())))
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ if ( viewId!=null && facesContext!=null && facesContext.getViewRoot()!=null )
+ {
+ Page currentPage = Pages.instance().getPage( facesContext.getViewRoot().getViewId() );
+ Page targetPage = Pages.instance().getPage(viewId);
+ if ( isDifferentConversationId( currentPage.getConversationIdParameter(), targetPage.getConversationIdParameter() ) )
{
- updateCurrentConversationId(target.getConversationIdParameter().getInitialConversationId());
+ updateCurrentConversationId( targetPage.getConversationIdParameter().getInitialConversationId( facesContext.getExternalContext().getRequestParameterMap() ) );
}
}
}
+ private boolean isDifferentConversationId(ConversationIdParameter sp, ConversationIdParameter tp)
+ {
+ return sp.getName()!=tp.getName() && ( sp==null || !sp.getName().equals( tp.getName() ) );
+ }
+
/**
* Add the conversation id to a URL, if necessary
*/
1.105 +0 -1 jboss-seam/src/main/org/jboss/seam/core/Pages.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Pages.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Pages.java,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -b -r1.104 -r1.105
--- Pages.java 8 Mar 2007 09:25:00 -0000 1.104
+++ Pages.java 9 Mar 2007 00:17:51 -0000 1.105
@@ -50,7 +50,6 @@
import org.jboss.seam.pages.RedirectNavigationHandler;
import org.jboss.seam.pages.RenderNavigationHandler;
import org.jboss.seam.pages.Rule;
-import org.jboss.seam.pages.SyntheticConversationIdParameter;
import org.jboss.seam.pages.TaskControl;
import org.jboss.seam.security.Identity;
import org.jboss.seam.security.NotLoggedInException;
More information about the jboss-cvs-commits
mailing list