You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by im...@apache.org on 2006/11/13 19:11:47 UTC

svn commit: r474422 - in /myfaces/tomahawk/trunk/sandbox/core/src/main: java/org/apache/myfaces/custom/conversation/ tld/entities/

Author: imario
Date: Mon Nov 13 10:11:47 2006
New Revision: 474422

URL: http://svn.apache.org/viewvc?view=rev&rev=474422
Log:
add preCheck which allows to delegate the conversation check to the action method at all

Modified:
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/EnsureConversationTag.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIEnsureConversation.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/ensure_conversation_attributes.xml

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/EnsureConversationTag.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/EnsureConversationTag.java?view=diff&rev=474422&r1=474421&r2=474422
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/EnsureConversationTag.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/EnsureConversationTag.java Mon Nov 13 10:11:47 2006
@@ -29,6 +29,7 @@
 {
 	private String redirectTo;
 	private String action;
+	private String preCheck;
 
 	public String getComponentType()
 	{
@@ -41,6 +42,7 @@
 
 		setStringProperty(component, "redirectTo", getRedirectTo());
 		setActionProperty(component, getAction());
+		setBooleanProperty(component, "preCheck", getPreCheck());
     }
 
 	public String getRedirectTo()
@@ -61,5 +63,15 @@
 	public void setAction(String action)
 	{
 		this.action = action;
+	}
+
+	public String getPreCheck()
+	{
+		return preCheck;
+	}
+
+	public void setPreCheck(String preCheck)
+	{
+		this.preCheck = preCheck;
 	}
 }

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIEnsureConversation.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIEnsureConversation.java?view=diff&rev=474422&r1=474421&r2=474422
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIEnsureConversation.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIEnsureConversation.java Mon Nov 13 10:11:47 2006
@@ -40,6 +40,7 @@
 	public static final String COMPONENT_TYPE = "org.apache.myfaces.EnsureConversation";
 
 	private String redirectTo;
+	private Boolean preCheck;
 
 	public void encodeBegin(FacesContext context) throws IOException
 	{
@@ -68,6 +69,7 @@
 
 		super.restoreState(context, states[0]);
 		redirectTo = (String) states[1];
+		preCheck = (Boolean) states[2];
 	}
 
 	public Object saveState(FacesContext context)
@@ -75,14 +77,28 @@
 		return new Object[]
 			{
 				super.saveState(context),
-				redirectTo
+				redirectTo,
+				preCheck
 			};
 	}
 
 	protected void checkConversation(FacesContext context, String name) throws IOException
 	{
 		ConversationManager conversationManager = ConversationManager.getInstance();
-		if (!conversationManager.hasConversation(name))
+
+		if (Boolean.TRUE.equals(preCheck))
+		{
+			String actionResult = (String) getAction().invoke(context, null);
+			if (actionResult == null)
+			{
+				// no further action, maybe the user started a conversation
+				return;
+			}
+
+			conversationManager.getMessager().setConversationNotActive(context, getName());
+			return;
+		}
+		else if (!conversationManager.hasConversation(name))
 		{
 			if (getAction() != null)
 			{
@@ -100,7 +116,7 @@
 			else
 			{
 				conversationManager.getMessager().setConversationNotActive(context, getName());
-				
+
 				String actionUrl = context.getApplication().getViewHandler().getActionURL(
 							context, getRedirectTo());
 				String encodedActionUrl = context.getExternalContext().encodeActionURL(actionUrl);

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/ensure_conversation_attributes.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/ensure_conversation_attributes.xml?view=diff&rev=474422&r1=474421&r2=474422
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/ensure_conversation_attributes.xml (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/ensure_conversation_attributes.xml Mon Nov 13 10:11:47 2006
@@ -13,4 +13,13 @@
 	<description>
 		the action which should be called in case of a not running conversation
 	</description>
-</attribute>
\ No newline at end of file
+</attribute>
+<attribute>
+	<name>preCheck</name>
+	<required>false</required>
+	<rtexprvalue>false</rtexprvalue>
+	<description>
+		Delegate the check to the action method at all. The user has to check if a conversation
+		is running. A action method is mandatory.
+	</description>
+</attribute
\ No newline at end of file