[jboss-cvs] jboss-seam/src/main/org/jboss/seam/core ...
Gavin King
gavin.king at jboss.com
Mon Jun 18 13:27:22 EDT 2007
User: gavin
Date: 07/06/18 13:27:22
Modified: src/main/org/jboss/seam/core ConversationEntry.java
Jbpm.java Manager.java Pageflow.java
ProcessInstance.java Switcher.java
Log:
JBSEAM-1112
fix a problem with interception of pageflow actions
Revision Changes Path
1.39 +9 -17 jboss-seam/src/main/org/jboss/seam/core/ConversationEntry.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ConversationEntry.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/ConversationEntry.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- ConversationEntry.java 8 Mar 2007 09:26:15 -0000 1.38
+++ ConversationEntry.java 18 Jun 2007 17:27:22 -0000 1.39
@@ -99,28 +99,20 @@
public void select()
{
- switchConversation();
+ redirect();
}
- public boolean switchConversation()
- {
- boolean success = Manager.instance().switchConversation( getId() );
- if (success)
+ public boolean redirect()
{
String viewId = getViewId();
- if (viewId!=null)
- {
- Manager.instance().redirect(viewId);
- return true;
- }
- else
+ if (viewId==null)
{
return false;
}
- }
else
{
- return false;
+ Manager.instance().redirect( viewId, getId() );
+ return true;
}
}
1.45 +5 -0 jboss-seam/src/main/org/jboss/seam/core/Jbpm.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Jbpm.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Jbpm.java,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -b -r1.44 -r1.45
--- Jbpm.java 17 Jun 2007 22:51:00 -0000 1.44
+++ Jbpm.java 18 Jun 2007 17:27:22 -0000 1.45
@@ -137,6 +137,11 @@
return pageflowProcessDefinitions.get(pageflowName);
}
+ public boolean isPageflowProcessDefinition(String pageflowName)
+ {
+ return pageflowProcessDefinitions.containsKey(pageflowName);
+ }
+
public ProcessDefinition getPageflowDefinitionFromResource(String resourceName)
{
InputStream resource = Resources.getResourceAsStream(resourceName);
1.173 +33 -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.172
retrieving revision 1.173
diff -u -b -r1.172 -r1.173
--- Manager.java 18 Jun 2007 05:12:19 -0000 1.172
+++ Manager.java 18 Jun 2007 17:27:22 -0000 1.173
@@ -759,6 +759,16 @@
return encodeConversationIdParameter( url, cip.getParameterName(), cip.getParameterValue() );
}
+ /**
+ * Add the conversation id to a URL, if necessary
+ */
+ public String encodeConversationId(String url, String viewId, String conversationId)
+ {
+ //DONT BREAK, icefaces uses this
+ ConversationIdParameter cip = Pages.instance().getPage(viewId).getConversationIdParameter();
+ return encodeConversationIdParameter( url, cip.getParameterName(), conversationId );
+ }
+
private String encodeConversationIdParameter(String url, String paramName, String paramValue)
{
@@ -896,8 +906,8 @@
}
/**
- * Redirect to the given view id, after encoding parameters and conversation id
- * into the request URL.
+ * Redirect to the given view id, after encoding parameters and conversation
+ * id into the request URL.
*
* @param viewId the JSF view id
* @param parameters request parameters to be encoded (possibly null)
@@ -927,6 +937,26 @@
beforeRedirect(viewId);
url = encodeConversationId(url, viewId);
}
+ redirect(viewId, context, url);
+ }
+
+ /**
+ * Redirect to the given view id, after encoding the given conversation
+ * id into the request URL.
+ *
+ * @param viewId the JSF view id
+ * @param conversationId an id of a long-running conversation
+ */
+ public void redirect(String viewId, String conversationId)
+ {
+ FacesContext context = FacesContext.getCurrentInstance();
+ String url = context.getApplication().getViewHandler().getActionURL(context, viewId);
+ url = encodeConversationId(url, viewId, conversationId);
+ redirect(viewId, context, url);
+ }
+
+ private void redirect(String viewId, FacesContext context, String url)
+ {
url = Pages.instance().encodeScheme(viewId, context, url);
if ( log.isDebugEnabled() )
{
@@ -946,7 +976,7 @@
{
controllingRedirect = false;
}
- context.responseComplete(); //work around MyFaces bug in 1.1.1
+ context.responseComplete();
}
/**
1.51 +9 -6 jboss-seam/src/main/org/jboss/seam/core/Pageflow.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Pageflow.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Pageflow.java,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -b -r1.50 -r1.51
--- Pageflow.java 12 Feb 2007 16:47:28 -0000 1.50
+++ Pageflow.java 18 Jun 2007 17:27:22 -0000 1.51
@@ -11,8 +11,6 @@
import javax.faces.context.FacesContext;
import javax.faces.event.PhaseId;
-import org.jboss.seam.log.LogProvider;
-import org.jboss.seam.log.Logging;
import org.jboss.seam.Component;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Install;
@@ -22,6 +20,8 @@
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.contexts.Lifecycle;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
import org.jboss.seam.pageflow.Page;
import org.jboss.seam.pageflow.PageflowHelper;
import org.jbpm.graph.def.Action;
@@ -58,11 +58,13 @@
return processInstance!=null;
}
- public ProcessInstance getProcessInstance() {
+ public ProcessInstance getProcessInstance()
+ {
return processInstance;
}
- public void setProcessInstance(ProcessInstance processInstance) {
+ public void setProcessInstance(ProcessInstance processInstance)
+ {
this.processInstance = processInstance;
setDirty();
}
@@ -187,7 +189,7 @@
public Page getPage()
{
Node node = getNode();
- if ( !(node instanceof Page) )
+ if ( node!=null && !(node instanceof Page) )
{
throw new IllegalStateException("pageflow is not currently at a <page> or <start-page> node (note that pageflows that begin during the RENDER_RESPONSE phase should use <start-page> instead of <start-state>)");
}
@@ -250,7 +252,8 @@
*/
public String getPageViewId()
{
- return getViewId( getPage() );
+ Page page = getPage();
+ return page==null ? null : getViewId(page);
}
/**
1.22 +0 -1 jboss-seam/src/main/org/jboss/seam/core/ProcessInstance.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ProcessInstance.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/ProcessInstance.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- ProcessInstance.java 3 Jun 2007 17:52:15 -0000 1.21
+++ ProcessInstance.java 18 Jun 2007 17:27:22 -0000 1.22
@@ -24,7 +24,6 @@
* jBPM ProcessInstance.
*
* @author Gavin King
- * @version $Revision: 1.21 $
*/
@Scope(ScopeType.STATELESS)
@Name("org.jboss.seam.core.processInstance")
1.21 +12 -18 jboss-seam/src/main/org/jboss/seam/core/Switcher.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Switcher.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Switcher.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- Switcher.java 10 Jun 2007 19:25:58 -0000 1.20
+++ Switcher.java 18 Jun 2007 17:27:22 -0000 1.21
@@ -10,7 +10,6 @@
import java.util.Set;
import java.util.TreeSet;
-import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import org.jboss.seam.ScopeType;
@@ -19,19 +18,20 @@
import org.jboss.seam.annotations.Intercept;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.contexts.Lifecycle;
/**
* Support for the conversation switcher drop-down menu.
*
* @author Gavin King
- * @version $Revision: 1.20 $
+ * @version $Revision: 1.21 $
*/
@Scope(ScopeType.PAGE)
@Name("org.jboss.seam.core.switcher")
@Install(precedence=BUILT_IN)
@Intercept(NEVER)
-public class Switcher implements Serializable {
+public class Switcher implements Serializable
+{
+
private static final long serialVersionUID = -6403911073853051938L;
private List<SelectItem> selectItems;
private String conversationIdOrOutcome;
@@ -83,43 +83,37 @@
}
}
- public String getConversationIdOrOutcome() {
+ public String getConversationIdOrOutcome()
+ {
return resultingConversationIdOrOutcome==null ?
getLongRunningConversationId() :
resultingConversationIdOrOutcome;
}
- public void setConversationIdOrOutcome(String selectedId) {
+ public void setConversationIdOrOutcome(String selectedId)
+ {
this.conversationIdOrOutcome = selectedId;
}
public String select()
{
- Manager manager = Manager.instance();
boolean isOutcome = conversationIdOrOutcome==null || !Character.isDigit( conversationIdOrOutcome.charAt(0) );
String actualOutcome;
if (isOutcome)
{
- manager.initializeTemporaryConversation();
resultingConversationIdOrOutcome = conversationIdOrOutcome;
actualOutcome = conversationIdOrOutcome;
}
else
{
- boolean success = manager.switchConversation(conversationIdOrOutcome);
- if (success)
+ ConversationEntry ce = ConversationEntries.instance().getConversationEntry(conversationIdOrOutcome);
+ if (ce!=null)
{
- resultingConversationIdOrOutcome = manager.getCurrentConversationId();
-
- String viewId = manager.getCurrentConversationViewId();
- if (viewId!=null)
- {
- Manager.instance().redirect(viewId);
- }
+ resultingConversationIdOrOutcome = ce.getId();
+ ce.redirect();
}
actualOutcome = null;
}
- Lifecycle.resumeConversation( FacesContext.getCurrentInstance().getExternalContext() ); //TODO: remove, unnecessary
return actualOutcome;
}
More information about the jboss-cvs-commits
mailing list