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/04/26 22:37:16 UTC
svn commit: r397294 - in /myfaces/tomahawk/trunk/sandbox:
core/src/main/java/org/apache/myfaces/custom/conversation/
core/src/main/resources-facesconfig/META-INF/ core/src/main/tld/
core/src/main/tld/entities/ examples/src/main/java/org/apache/myfaces/...
Author: imario
Date: Wed Apr 26 13:37:14 2006
New Revision: 397294
URL: http://svn.apache.org/viewcvs?rev=397294&view=rev
Log:
conversationTag - this is non working, highly fluctuating and undocumented code. Its just committed to have it on a save place in case my harddisk crashes.
Please do not comment this code ;-) - again - its non functional yet
Added:
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/AbstractConversationActionListener.java (with props)
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/AbstractConversationComponent.java (with props)
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/AbstractConversationTag.java (with props)
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/Conversation.java (with props)
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationContext.java (with props)
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationListener.java (with props)
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationManager.java (with props)
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationPhaseListener.java (with props)
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationTag.java (with props)
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationUtils.java (with props)
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/EndConversationTag.java (with props)
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/StartConversationTag.java (with props)
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIConversation.java (with props)
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIEndConversation.java (with props)
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIStartConversation.java (with props)
myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/conversation_attributes.xml (with props)
myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/standard_conversation_attributes.xml (with props)
myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/conversation/
myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/conversation/ConvData.java (with props)
myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pageConversation.jsp (with props)
Modified:
myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml
myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld
myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/WEB-INF/web.xml
myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/AbstractConversationActionListener.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/AbstractConversationActionListener.java?rev=397294&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/AbstractConversationActionListener.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/AbstractConversationActionListener.java Wed Apr 26 13:37:14 2006
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.conversation;
+
+import java.io.Serializable;
+
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ActionListener;
+import javax.faces.event.PhaseId;
+
+/**
+ * base class to handle actions events
+ * @author imario@apache.org
+ */
+public abstract class AbstractConversationActionListener implements ActionListener, Serializable
+{
+ private String conversationName;
+
+ public AbstractConversationActionListener()
+ {
+ }
+
+ public String getConversationName()
+ {
+ return conversationName;
+ }
+
+ public void setConversationName(String conversationName)
+ {
+ this.conversationName = conversationName;
+ }
+
+ public void processAction(ActionEvent actionEvent) throws AbortProcessingException
+ {
+ AbstractConversationComponent startOrEndconversation = ConversationUtils.findStartOrEndConversationComponent(actionEvent.getComponent(), getConversationName());
+
+ doConversationAction(startOrEndconversation);
+ }
+
+ public abstract void doConversationAction(AbstractConversationComponent abstractConversationComponent);
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/AbstractConversationActionListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/AbstractConversationActionListener.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/AbstractConversationActionListener.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/AbstractConversationComponent.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/AbstractConversationComponent.java?rev=397294&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/AbstractConversationComponent.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/AbstractConversationComponent.java Wed Apr 26 13:37:14 2006
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.conversation;
+
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+
+/**
+ * base class for all the conversation components
+ * @author imario@apache.org
+ */
+public class AbstractConversationComponent extends UIComponentBase
+{
+ public static final String COMPONENT_FAMILY = "javax.faces.Component";
+
+ private String name;
+
+ public String getFamily()
+ {
+ return COMPONENT_FAMILY;
+ }
+
+ public void restoreState(FacesContext context, Object state)
+ {
+ Object[] states = (Object[]) state;
+
+ super.restoreState(context, states[0]);
+ name = (String) states[1];
+ }
+
+ public Object saveState(FacesContext context)
+ {
+ return new Object[]
+ {
+ super.saveState(context),
+ name
+ };
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/AbstractConversationComponent.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/AbstractConversationComponent.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/AbstractConversationComponent.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/AbstractConversationTag.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/AbstractConversationTag.java?rev=397294&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/AbstractConversationTag.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/AbstractConversationTag.java Wed Apr 26 13:37:14 2006
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.conversation;
+
+import javax.faces.component.UIComponent;
+
+import org.apache.myfaces.shared_tomahawk.taglib.UIComponentTagBase;
+
+/**
+ * base class for all conversation tags
+ * @author im
+ */
+public abstract class AbstractConversationTag extends UIComponentTagBase
+{
+ private String name;
+
+ public String getRendererType()
+ {
+ return null;
+ }
+
+ protected void setProperties(UIComponent component)
+ {
+ super.setProperties(component);
+ setStringProperty(component, "name", name);
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String alias)
+ {
+ this.name = alias;
+ }
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/AbstractConversationTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/AbstractConversationTag.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/AbstractConversationTag.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/Conversation.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/Conversation.java?rev=397294&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/Conversation.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/Conversation.java Wed Apr 26 13:37:14 2006
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.conversation;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * handle conversation related stuff like beans
+ * @author imario@apache.org
+ */
+public class Conversation
+{
+ private final String name;
+
+ private final Map beans = new TreeMap();
+
+ protected Conversation(String name)
+ {
+ this.name = name;
+ }
+
+ public void putBean(String name, Object bean)
+ {
+ beans.put(name, bean);
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void endConversation()
+ {
+ Iterator iterBeans = beans.values().iterator();
+ while (iterBeans.hasNext())
+ {
+ Object bean = iterBeans.next();
+ if (bean instanceof ConversationListener)
+ {
+ ((ConversationListener) bean).conversationEnded();
+ }
+ }
+ beans.clear();
+ }
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/Conversation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/Conversation.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/Conversation.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationContext.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationContext.java?rev=397294&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationContext.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationContext.java Wed Apr 26 13:37:14 2006
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.conversation;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * The ConversationContext handles all conversations within the current context
+ *
+ * @author imario@apache.org
+ */
+public class ConversationContext
+{
+ private final Map conversations = new TreeMap();
+ private final List conversationStack = new ArrayList(10);
+ private Conversation currentConversation;
+
+ protected ConversationContext()
+ {
+ }
+
+ public void startConversation(String name)
+ {
+ Conversation conversation = (Conversation) conversations.get(name);
+ if (conversation == null)
+ {
+ conversation = new Conversation(name);
+ conversations.put(name, conversation);
+ conversationStack.add(conversation);
+ }
+ else
+ {
+ endDependingConversations(conversation);
+ }
+ currentConversation = conversation;
+ }
+
+ protected void endDependingConversations(Conversation conversation)
+ {
+ while (conversationStack.size()>0)
+ {
+ int index = conversationStack.size()-1;
+ Conversation dependingConversation = (Conversation) conversationStack.get(index);
+ if (conversation == dependingConversation)
+ {
+ return;
+ }
+
+ endConversation((Conversation) conversationStack.remove(index));
+ }
+ }
+
+ protected void endConversation(Conversation conversation)
+ {
+ conversation.endConversation();
+ }
+
+ public void endConversation(String name)
+ {
+ Conversation conversation = (Conversation) conversations.remove(name);
+ if (conversation != null)
+ {
+ while (conversationStack.size()>0)
+ {
+ Conversation dependingConversation = (Conversation) conversationStack.remove(conversationStack.size()-1);
+ endConversation(dependingConversation);
+ if (dependingConversation == conversation)
+ {
+ if (conversationStack.size() > 0)
+ {
+ currentConversation = (Conversation) conversationStack.get(conversationStack.size()-1);
+ }
+ return;
+ }
+ }
+ }
+ }
+
+ public Conversation getCurrentConversation()
+ {
+ return currentConversation;
+ }
+
+ public boolean hasConversation()
+ {
+ return conversations.size() > 0;
+ }
+
+ public Conversation getConversation(String name)
+ {
+ return (Conversation) conversations.get(name);
+ }
+}
\ No newline at end of file
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationContext.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationContext.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationListener.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationListener.java?rev=397294&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationListener.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationListener.java Wed Apr 26 13:37:14 2006
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.conversation;
+
+/**
+ * all beans implementing this listener will get informed if a conversation ends
+ * @author imario@apache.org
+ */
+public interface ConversationListener
+{
+ public void conversationEnded();
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationListener.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationListener.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationManager.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationManager.java?rev=397294&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationManager.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationManager.java Wed Apr 26 13:37:14 2006
@@ -0,0 +1,163 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.conversation;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * The manager will deal with the various contexts in the current session.
+ * A new context will be created if the current window has none associated.
+ *
+ * @author imario@apache.org
+ */
+public class ConversationManager
+{
+ private final static String CONVERSATION_MANAGER_KEY = "org.apache.myfaces.ConversationManager";
+ private final static String CONVERSATION_CONTEXT_PARAM = "conversationContext";
+ private final static String CONVERSATION_CONTEXT_REQ = "org.apache.myfaces.ConversationManager.conversationContext";
+
+ private static long NEXT_CONVERSATION_CONTEXT = 1;
+
+ private final Map conversationContexts = new HashMap();
+
+ private final List registeredEndConversations = new ArrayList(10);
+
+ protected ConversationManager()
+ {
+ }
+
+ public static ConversationManager getInstance()
+ {
+ FacesContext context = FacesContext.getCurrentInstance();
+ if (context == null)
+ {
+ throw new IllegalStateException("no faces context available");
+ }
+ return getInstance(context);
+ }
+
+ public static ConversationManager getInstance(FacesContext context)
+ {
+ ConversationManager conversationManager = (ConversationManager) context.getExternalContext().getSessionMap().get(CONVERSATION_MANAGER_KEY);
+ if (conversationManager == null)
+ {
+ conversationManager = new ConversationManager();
+ context.getExternalContext().getSessionMap().put(CONVERSATION_MANAGER_KEY, conversationManager);
+ }
+
+ return conversationManager;
+ }
+
+ protected Long getConversationContextId()
+ {
+ FacesContext context = FacesContext.getCurrentInstance();
+
+ Long conversationContextId = (Long) context.getExternalContext().getRequestMap().get(CONVERSATION_CONTEXT_REQ);
+ if (conversationContextId == null)
+ {
+ if (context.getExternalContext().getRequestParameterMap().containsKey(CONVERSATION_CONTEXT_PARAM))
+ {
+ String urlConversationContextId = context.getExternalContext().getRequestParameterMap().get(CONVERSATION_CONTEXT_PARAM).toString();
+ conversationContextId = new Long(Long.parseLong(urlConversationContextId, Character.MAX_RADIX));
+ }
+ else
+ {
+ synchronized (ConversationManager.class)
+ {
+ conversationContextId = new Long(NEXT_CONVERSATION_CONTEXT);
+ NEXT_CONVERSATION_CONTEXT++;
+ }
+ }
+
+ context.getExternalContext().getRequestMap().put(CONVERSATION_CONTEXT_REQ, conversationContextId);
+ }
+
+ return conversationContextId;
+ }
+
+ protected ConversationContext getConversationContext(Long conversationContextId)
+ {
+ return (ConversationContext) conversationContexts.get(conversationContextId);
+ }
+
+ protected ConversationContext getOrCreateConversationContext(Long conversationContextId)
+ {
+ ConversationContext conversationContext = (ConversationContext) conversationContexts.get(conversationContextId);
+ if (conversationContext == null)
+ {
+ conversationContext = new ConversationContext();
+ conversationContexts.put(conversationContextId, conversationContext);
+ }
+
+ return conversationContext;
+ }
+
+ protected void destroyConversationContext(Long conversationContextId)
+ {
+ conversationContexts.remove(conversationContextId);
+ }
+
+ public void startConversation(String name)
+ {
+ Long conversationContextId = getConversationContextId();
+ ConversationContext conversationContext = getOrCreateConversationContext(conversationContextId);
+ conversationContext.startConversation(name);
+ }
+
+ public void endConversation(String name)
+ {
+ Long conversationContextId = getConversationContextId();
+ ConversationContext conversationContext = getConversationContext(conversationContextId);
+ if (conversationContext != null)
+ {
+ conversationContext.endConversation(name);
+
+ if (!conversationContext.hasConversation())
+ {
+ destroyConversationContext(conversationContextId);
+ }
+ }
+ }
+
+ public Conversation getConversation(String name)
+ {
+ Long conversationContextId = getConversationContextId();
+ ConversationContext conversationContext = getConversationContext(conversationContextId);
+ if (conversationContext == null)
+ {
+ return null;
+ }
+ return conversationContext.getConversation(name);
+ }
+
+ public void registerEndConversation(String conversationName)
+ {
+ synchronized (registeredEndConversations)
+ {
+ registeredEndConversations.add(conversationName);
+ }
+ }
+
+ public List getRegisteredEndConversations()
+ {
+ return registeredEndConversations;
+ }
+}
\ No newline at end of file
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationManager.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationManager.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationPhaseListener.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationPhaseListener.java?rev=397294&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationPhaseListener.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationPhaseListener.java Wed Apr 26 13:37:14 2006
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.conversation;
+
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+
+/**
+ * e.g. handle delayed endConversation for tags within command* tag
+ * @author imario@apache.org
+ */
+public class ConversationPhaseListener implements PhaseListener
+{
+ public void afterPhase(PhaseEvent event)
+ {
+ ConversationManager conversationManager = ConversationManager.getInstance();
+ endConversations(conversationManager);
+ }
+
+ protected void endConversations(ConversationManager conversationManager)
+ {
+ List registeredEndConversations = conversationManager.getRegisteredEndConversations();
+ if (registeredEndConversations.size() > 0)
+ {
+ synchronized (registeredEndConversations)
+ {
+ Iterator iterRegisteredEndConversations = conversationManager.getRegisteredEndConversations().iterator();
+ while (iterRegisteredEndConversations.hasNext())
+ {
+ String conversationName = (String) iterRegisteredEndConversations.next();
+ conversationManager.endConversation(conversationName);
+ }
+ registeredEndConversations.clear();
+ }
+ }
+ }
+
+ public void beforePhase(PhaseEvent event)
+ {
+ }
+
+ public PhaseId getPhaseId()
+ {
+ return PhaseId.INVOKE_APPLICATION;
+ }
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationPhaseListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationPhaseListener.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationPhaseListener.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationTag.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationTag.java?rev=397294&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationTag.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationTag.java Wed Apr 26 13:37:14 2006
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.conversation;
+
+import javax.faces.component.UIComponent;
+
+/**
+ * associate a bean to the named context
+ *
+ * @author imario@apache.org
+ */
+public class ConversationTag extends AbstractConversationTag
+{
+ public String getComponentType()
+ {
+ return UIConversation.COMPONENT_TYPE;
+ }
+
+ protected void setProperties(UIComponent component)
+ {
+ super.setProperties(component);
+ }
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationTag.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationTag.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationUtils.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationUtils.java?rev=397294&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationUtils.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationUtils.java Wed Apr 26 13:37:14 2006
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.conversation;
+
+import java.util.Iterator;
+
+import javax.faces.component.UICommand;
+import javax.faces.component.UIComponent;
+
+public class ConversationUtils
+{
+ private ConversationUtils()
+ {
+ }
+
+ public static UICommand findParentCommand(UIComponent base)
+ {
+ UIComponent parent = base;
+ do
+ {
+ parent = parent.getParent();
+ if (parent instanceof UICommand)
+ {
+ return (UICommand) parent;
+ }
+ }
+ while (parent != null);
+
+ return null;
+ }
+
+ public static AbstractConversationComponent findStartOrEndConversationComponent(UIComponent component, String conversationName)
+ {
+ Iterator iterComponents = component.getFacetsAndChildren();
+ while (iterComponents.hasNext())
+ {
+ Object child = iterComponents.next();
+ AbstractConversationComponent conversation;
+
+ if (child instanceof UIStartConversation || child instanceof UIEndConversation)
+ {
+ conversation = (AbstractConversationComponent) child;
+ if (conversation.getName().equals(conversationName))
+ {
+ return conversation;
+ }
+ }
+ else if (child instanceof UIComponent)
+ {
+ conversation = findStartOrEndConversationComponent((UIComponent) child, conversationName);
+ if (conversation != null)
+ {
+ return conversation;
+ }
+ }
+ }
+
+ return null;
+ }
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationUtils.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/ConversationUtils.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/EndConversationTag.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/EndConversationTag.java?rev=397294&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/EndConversationTag.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/EndConversationTag.java Wed Apr 26 13:37:14 2006
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.conversation;
+
+import javax.faces.component.UIComponent;
+
+/**
+ * Ends a conversation
+ *
+ * @author imario@apache.org
+ */
+public class EndConversationTag extends AbstractConversationTag
+{
+ public String getComponentType()
+ {
+ return UIEndConversation.COMPONENT_TYPE;
+ }
+
+ protected void setProperties(UIComponent component)
+ {
+ super.setProperties(component);
+ }
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/EndConversationTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/EndConversationTag.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/EndConversationTag.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/StartConversationTag.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/StartConversationTag.java?rev=397294&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/StartConversationTag.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/StartConversationTag.java Wed Apr 26 13:37:14 2006
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.conversation;
+
+import javax.faces.component.UIComponent;
+
+/**
+ * Introduces a new conversation
+ *
+ * @author imario@apache.org
+ */
+public class StartConversationTag extends AbstractConversationTag
+{
+ public String getComponentType()
+ {
+ return UIStartConversation.COMPONENT_TYPE;
+ }
+
+ protected void setProperties(UIComponent component)
+ {
+ super.setProperties(component);
+ }
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/StartConversationTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/StartConversationTag.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/StartConversationTag.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIConversation.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIConversation.java?rev=397294&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIConversation.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIConversation.java Wed Apr 26 13:37:14 2006
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.conversation;
+
+import java.io.IOException;
+
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+
+/**
+ * add a bean under context control
+ *
+ * @author imario@apache.org
+ */
+public class UIConversation extends AbstractConversationComponent
+{
+ public static final String COMPONENT_TYPE = "org.apache.myfaces.Conversation";
+
+ public void encodeBegin(FacesContext context) throws IOException
+ {
+ super.encodeBegin(context);
+
+ elevateBean(context);
+ }
+
+ public void elevateBean(FacesContext context)
+ {
+ Conversation conversation = ConversationManager.getInstance().getConversation(getName());
+ if (conversation == null)
+ {
+ throw new IllegalStateException("no conversation named '" + getName() + "' running");
+ }
+
+ ValueBinding vb = getValueBinding("value");
+ conversation.putBean(vb.getExpressionString(), vb.getValue(context));
+ }
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIConversation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIConversation.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIConversation.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIEndConversation.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIEndConversation.java?rev=397294&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIEndConversation.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIEndConversation.java Wed Apr 26 13:37:14 2006
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.conversation;
+
+import java.io.IOException;
+
+import javax.faces.component.UICommand;
+import javax.faces.context.FacesContext;
+
+/**
+ * end a conversation
+ *
+ * @author imario@apache.org
+ */
+public class UIEndConversation extends AbstractConversationComponent
+{
+ public static final String COMPONENT_TYPE = "org.apache.myfaces.EndConversation";
+
+ private boolean inited = false;
+
+ public static class ConversationEndAction extends AbstractConversationActionListener
+ {
+ public void doConversationAction(AbstractConversationComponent abstractConversationComponent)
+ {
+ ConversationManager.getInstance().registerEndConversation(getConversationName());
+ }
+ }
+
+ public void encodeBegin(FacesContext context) throws IOException
+ {
+ super.encodeBegin(context);
+
+ UICommand command = ConversationUtils.findParentCommand(this);
+ if (command != null)
+ {
+ if (!inited)
+ {
+ ConversationEndAction actionListener = new ConversationEndAction();
+ actionListener.setConversationName(getName());
+ command.addActionListener(actionListener);
+ inited = true;
+ }
+ }
+ else
+ {
+ ConversationManager conversationManager = ConversationManager.getInstance();
+ conversationManager.endConversation(getName());
+ }
+ }
+
+ public void restoreState(FacesContext context, Object state)
+ {
+ Object[] states = (Object[]) state;
+ super.restoreState(context, states[0]);
+ inited = ((Boolean) states[1]).booleanValue();
+ }
+
+ public Object saveState(FacesContext context)
+ {
+ return new Object[]
+ {
+ super.saveState(context),
+ inited?Boolean.TRUE:Boolean.FALSE
+ };
+ }
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIEndConversation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIEndConversation.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIEndConversation.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIStartConversation.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIStartConversation.java?rev=397294&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIStartConversation.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIStartConversation.java Wed Apr 26 13:37:14 2006
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.conversation;
+
+import java.io.IOException;
+
+import javax.faces.component.UICommand;
+import javax.faces.context.FacesContext;
+
+/**
+ * start a conversation
+ *
+ * @author imario@apache.org
+ */
+public class UIStartConversation extends AbstractConversationComponent
+{
+ public static final String COMPONENT_TYPE = "org.apache.myfaces.StartConversation";
+
+ private boolean inited;
+
+ public static class ConversationStartAction extends AbstractConversationActionListener
+ {
+ public void doConversationAction(AbstractConversationComponent abstractConversationComponent)
+ {
+ ConversationManager conversationManager = ConversationManager.getInstance();
+ conversationManager.startConversation(getConversationName());
+ }
+ }
+
+ public void encodeBegin(FacesContext context) throws IOException
+ {
+ super.encodeBegin(context);
+
+ UICommand command = ConversationUtils.findParentCommand(this);
+ if (command != null)
+ {
+ if (!inited)
+ {
+ ConversationStartAction actionListener = new ConversationStartAction();
+ actionListener.setConversationName(getName());
+ command.addActionListener(actionListener);
+ inited = true;
+ }
+ }
+ else
+ {
+ ConversationManager conversationManager = ConversationManager.getInstance();
+ conversationManager.startConversation(getName());
+ }
+ }
+
+ public void restoreState(FacesContext context, Object state)
+ {
+ Object[] states = (Object[]) state;
+ super.restoreState(context, states[0]);
+ inited = ((Boolean) states[1]).booleanValue();
+ }
+
+ public Object saveState(FacesContext context)
+ {
+ return new Object[]
+ {
+ super.saveState(context),
+ inited?Boolean.TRUE:Boolean.FALSE
+ };
+ }
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIStartConversation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIStartConversation.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/conversation/UIStartConversation.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml?rev=397294&r1=397293&r2=397294&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml Wed Apr 26 13:37:14 2006
@@ -124,6 +124,19 @@
<component-class>org.apache.myfaces.custom.scope.UIScope</component-class>
</component>
+ <component>
+ <component-type>org.apache.myfaces.StartConversation</component-type>
+ <component-class>org.apache.myfaces.custom.conversation.UIStartConversation</component-class>
+ </component>
+ <component>
+ <component-type>org.apache.myfaces.EndConversation</component-type>
+ <component-class>org.apache.myfaces.custom.conversation.UIEndConversation</component-class>
+ </component>
+ <component>
+ <component-type>org.apache.myfaces.Conversation</component-type>
+ <component-class>org.apache.myfaces.custom.conversation.UIConversation</component-class>
+ </component>
+
<component>
<component-type>org.apache.myfaces.HtmlSelectManyPicklist</component-type>
<component-class>org.apache.myfaces.custom.picklist.HtmlSelectManyPicklist</component-class>
@@ -374,7 +387,8 @@
<lifecycle>
<phase-listener>org.apache.myfaces.custom.ajax.api.AjaxDecodePhaseListener</phase-listener>
<phase-listener>org.apache.myfaces.custom.valueChangeNotifier.ValueChangePhaseListener</phase-listener>
- <phase-listener>org.apache.myfaces.custom.scope.AfterScopePhaseListener</phase-listener>
+ <phase-listener>org.apache.myfaces.custom.scope.AfterScopePhaseListener</phase-listener>
+ <phase-listener>org.apache.myfaces.custom.conversation.ConversationPhaseListener</phase-listener>
</lifecycle>
<!--custom validators -->
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/conversation_attributes.xml
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/conversation_attributes.xml?rev=397294&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/conversation_attributes.xml (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/conversation_attributes.xml Wed Apr 26 13:37:14 2006
@@ -0,0 +1,7 @@
+<attribute>
+ <name>value</name>
+ <required>true</required>
+ <rtexprvalue>false</rtexprvalue>
+ <type>java.lang.String</type>
+ <description>The bean reference.</description>
+</attribute>
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/conversation_attributes.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/conversation_attributes.xml
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/conversation_attributes.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/standard_conversation_attributes.xml
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/standard_conversation_attributes.xml?rev=397294&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/standard_conversation_attributes.xml (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/standard_conversation_attributes.xml Wed Apr 26 13:37:14 2006
@@ -0,0 +1,8 @@
+<attribute>
+ <name>name</name>
+ <required>true</required>
+ <rtexprvalue>false</rtexprvalue>
+ <description>
+ the name of the conversation to end
+ </description>
+</attribute>
\ No newline at end of file
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/standard_conversation_attributes.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/standard_conversation_attributes.xml
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/standard_conversation_attributes.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld?rev=397294&r1=397293&r2=397294&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld Wed Apr 26 13:37:14 2006
@@ -128,6 +128,8 @@
<!ENTITY suggest_ajax_attributes SYSTEM "entities/suggest_ajax_attributes.xml">
<!ENTITY html_fisheye_list_attributes SYSTEM "entities/html_fisheyelist_attributes.xml">
<!ENTITY html_timed_notifier_attributes SYSTEM "entities/html_timed_notifier_attributes.xml">
+<!ENTITY standard_conversation_attributes SYSTEM "entities/standard_conversation_attributes.xml">
+<!ENTITY conversation_attributes SYSTEM "entities/conversation_attributes.xml">
]>
<taglib>
@@ -1042,5 +1044,32 @@
&ui_component_attributes;
&html_timed_notifier_attributes;
+ </tag>
+
+ <!-- conversation -->
+ <tag>
+ <name>startConversation</name>
+ <tag-class>org.apache.myfaces.custom.conversation.StartConversationTag</tag-class>
+ <body-content>JSP</body-content>
+ <description>Starts a new conversation</description>
+
+ &standard_conversation_attributes;
+ </tag>
+ <tag>
+ <name>endConversation</name>
+ <tag-class>org.apache.myfaces.custom.conversation.EndConversationTag</tag-class>
+ <body-content>JSP</body-content>
+ <description>Ends a conversation</description>
+
+ &standard_conversation_attributes;
+ </tag>
+ <tag>
+ <name>conversation</name>
+ <tag-class>org.apache.myfaces.custom.conversation.ConversationTag</tag-class>
+ <body-content>JSP</body-content>
+ <description>puts a bean into the conversation context</description>
+
+ &standard_conversation_attributes;
+ &conversation_attributes;
</tag>
</taglib>
Added: myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/conversation/ConvData.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/conversation/ConvData.java?rev=397294&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/conversation/ConvData.java (added)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/conversation/ConvData.java Wed Apr 26 13:37:14 2006
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.examples.conversation;
+
+public class ConvData
+{
+ private String input;
+
+ public String getInput()
+ {
+ return input;
+ }
+
+ public void setInput(String input)
+ {
+ this.input = input;
+ }
+}
Propchange: myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/conversation/ConvData.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/conversation/ConvData.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/conversation/ConvData.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/WEB-INF/web.xml?rev=397294&r1=397293&r2=397294&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/WEB-INF/web.xml (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/WEB-INF/web.xml Wed Apr 26 13:37:14 2006
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
-<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4" id="WebApp_ID">
<description>debug web.xml</description>
+ <display-name>
+ tomahawk-sandbox-examples</display-name>
<context-param>
<description>Comma separated list of URIs of (additional) faces config files.
(e.g. /WEB-INF/my-config.xml)
@@ -100,7 +102,11 @@
<url-pattern>*.source</url-pattern>
</servlet-mapping>
<welcome-file-list>
- <welcome-file>index.jsp</welcome-file>
- <welcome-file>index.html</welcome-file>
+ <welcome-file>index.html</welcome-file>
+ <welcome-file>index.htm</welcome-file>
+ <welcome-file>index.jsp</welcome-file>
+ <welcome-file>default.html</welcome-file>
+ <welcome-file>default.htm</welcome-file>
+ <welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp?rev=397294&r1=397293&r2=397294&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp Wed Apr 26 13:37:14 2006
@@ -95,6 +95,11 @@
<h:outputLink value="killSession.jsf"><f:verbatim>Kill Session - refreshes state</f:verbatim></h:outputLink>
</h:panelGrid>
+ <h:outputText value="Conversation"/>
+ <h:panelGrid style="padding-left:25px">
+ <h:outputLink value="pageConversation.jsf" ><f:verbatim>Single page conversation</f:verbatim></h:outputLink>
+ </h:panelGrid>
+
</h:panelGrid>
</f:view>
Added: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pageConversation.jsp
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pageConversation.jsp?rev=397294&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pageConversation.jsp (added)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pageConversation.jsp Wed Apr 26 13:37:14 2006
@@ -0,0 +1,49 @@
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
+<%@ taglib uri="http://myfaces.apache.org/sandbox" prefix="s"%>
+
+<!--
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//-->
+
+<html>
+<head>
+<meta HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=UTF-8" />
+<title>MyFaces - the free JSF Implementation</title>
+<link rel="stylesheet" type="text/css" href="css/basic.css" />
+</head>
+<body>
+<f:view>
+<s:startConversation name="page" />
+<s:conversation name="page" value="#{convData}" />
+<h:panelGrid columns="2">
+ <h:outputText value="Enter something into this field: " />
+ <h:inputText value="#{convData.input}" />
+
+ <h:commandLink value="check value"/>
+ <h:commandLink value="save value">
+ <s:endConversation name="page" />
+ </h:commandLink>
+</h:panelGrid>
+<h:panelGrid columns="1">
+ <h:outputText value="Press 'check value' to simulate a server action witout ending the conversation" />
+ <h:outputText value="Press 'save value' to simulate a server action AND END the conversation" />
+</h:panelGrid>
+</f:view>
+</body>
+</html>
Propchange: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pageConversation.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pageConversation.jsp
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/pageConversation.jsp
------------------------------------------------------------------------------
svn:mime-type = text/plain