[webbeans-commits] Webbeans SVN: r1770 - in examples/trunk/numberguess: src/main/java/org/jboss/webbeans/examples/numberguess and 1 other directory.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Thu Mar 5 03:00:16 EST 2009


Author: nickarls
Date: 2009-03-05 03:00:16 -0500 (Thu, 05 Mar 2009)
New Revision: 1770

Added:
   examples/trunk/numberguess/WebContent/conversations.xhtml
   examples/trunk/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/Conversations.java
Log:
Temp conversation test piggybacking on the numberguess build

Added: examples/trunk/numberguess/WebContent/conversations.xhtml
===================================================================
--- examples/trunk/numberguess/WebContent/conversations.xhtml	                        (rev 0)
+++ examples/trunk/numberguess/WebContent/conversations.xhtml	2009-03-05 08:00:16 UTC (rev 1770)
@@ -0,0 +1,25 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+    xmlns:ui="http://java.sun.com/jsf/facelets"
+    xmlns:h="http://java.sun.com/jsf/html"
+    xmlns:f="http://java.sun.com/jsf/core">
+
+  <ui:composition template="template.xhtml">
+    <ui:define name="content">
+    	<h:form>
+    		<h:panelGrid columns="1">
+				<h:outputText value="Long-running: #{conversations.conversationList}"/>
+	    		<h:outputText value="Current: #{conversation}"/>
+	    		<h:panelGroup>
+    				<h:commandButton action="#{conversation.begin}" value="begin"/>
+    				<h:commandButton action="#{conversations.noop}" value="noop"/>
+    				<h:commandButton action="#{conversation.end}" value="end"/>
+    				<h:commandButton action="#{conversations.abandon}" value="abandon"/>
+    			</h:panelGroup>
+    			<h:inputText value="#{conversations.cid}"/>
+    			<h:commandButton action="#{conversations.switchConversation}" value="switch"/>
+    		</h:panelGrid>
+		</h:form>
+    </ui:define>
+  </ui:composition>
+</html>

Added: examples/trunk/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/Conversations.java
===================================================================
--- examples/trunk/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/Conversations.java	                        (rev 0)
+++ examples/trunk/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/Conversations.java	2009-03-05 08:00:16 UTC (rev 1770)
@@ -0,0 +1,72 @@
+package org.jboss.webbeans.examples.numberguess;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.Named;
+import javax.context.Conversation;
+import javax.context.SessionScoped;
+import javax.faces.model.SelectItem;
+import javax.inject.Current;
+import javax.inject.Produces;
+
+import java.io.Serializable;
+
+import org.jboss.webbeans.conversation.ConversationIdGenerator;
+import org.jboss.webbeans.conversation.ConversationManager;
+import org.jboss.webbeans.conversation.bindings.ConversationInactivityTimeout;
+
+ at SessionScoped
+ at Named("conversations")
+public class Conversations implements Serializable {
+
+   @Current private Conversation conversation;
+   @Current private ConversationIdGenerator id;
+   @Current private ConversationManager conversationManager;
+   private String cid;
+     
+   public Conversations() 
+   {
+   }
+   
+   public void abandon() 
+   {
+      conversation.begin(id.nextId());
+   }
+   
+   public void noop()
+   {
+   
+   }
+   
+   public Iterable<Conversation> getConversationList() 
+   {
+      return conversationManager.getLongRunningConversations(); 
+   }
+   
+   public List<SelectItem> getLongRunningConversations() 
+   {
+      List<SelectItem> longRunningConversations = new ArrayList<SelectItem>();
+      for (Conversation conversation : conversationManager.getLongRunningConversations()) 
+      {
+         longRunningConversations.add(new SelectItem(conversation.getId(), conversation.getId()));
+      }
+      return longRunningConversations;
+   }
+
+   public void switchConversation() 
+   {
+      conversation.begin(cid);
+   }
+   
+   public String getCid()
+   {
+      return cid;
+   }
+
+   public void setCid(String cid)
+   {
+      this.cid = cid;
+   }
+   
+}
\ No newline at end of file




More information about the weld-commits mailing list