openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r835495 - in /incubator/openwebbeans/trunk/samples/jsf2sample/src/main: java/org/apache/webbeans/jsf2/ConversationBean.java java/org/apache/webbeans/jsf2/ConversationData.java webapp/conversation.xhtml
Date Thu, 12 Nov 2009 18:42:32 GMT
Author: gerdogdu
Date: Thu Nov 12 18:42:32 2009
New Revision: 835495

URL: http://svn.apache.org/viewvc?rev=835495&view=rev
Log:
conversation support example

Added:
    incubator/openwebbeans/trunk/samples/jsf2sample/src/main/java/org/apache/webbeans/jsf2/ConversationBean.java
  (with props)
    incubator/openwebbeans/trunk/samples/jsf2sample/src/main/java/org/apache/webbeans/jsf2/ConversationData.java
  (with props)
    incubator/openwebbeans/trunk/samples/jsf2sample/src/main/webapp/conversation.xhtml   (with
props)

Added: incubator/openwebbeans/trunk/samples/jsf2sample/src/main/java/org/apache/webbeans/jsf2/ConversationBean.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/samples/jsf2sample/src/main/java/org/apache/webbeans/jsf2/ConversationBean.java?rev=835495&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/samples/jsf2sample/src/main/java/org/apache/webbeans/jsf2/ConversationBean.java
(added)
+++ incubator/openwebbeans/trunk/samples/jsf2sample/src/main/java/org/apache/webbeans/jsf2/ConversationBean.java
Thu Nov 12 18:42:32 2009
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You 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.webbeans.jsf2;
+
+import javax.enterprise.context.Conversation;
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+@Named
+@RequestScoped
+public class ConversationBean
+{
+    private @Inject Conversation conversation;
+    
+    private @Inject @Named("mynumber") int current;
+    
+    private String message;
+    
+    public ConversationBean()
+    {
+        
+    }
+    
+    public String startConversation()
+    {
+        conversation.begin();
+        
+        message = "Conversation is started with id : " + this.conversation.getId();
+        
+        return null;
+    }
+    
+    public String next()
+    {
+        return "next";
+    }
+    
+    public String stopConversation()
+    {
+        conversation.end();
+        
+        current = 10;
+        
+       message = "Conversation is ended";
+
+       return null;
+    }
+
+    /**
+     * @return the message
+     */
+    public String getMessage()
+    {
+        return message;
+    }
+
+    /**
+     * @param message the message to set
+     */
+    public void setMessage(String message)
+    {
+        this.message = message;
+    }
+
+    /**
+     * @return the conversation
+     */
+    public Conversation getConversation()
+    {
+        return conversation;
+    }
+
+    /**
+     * @param conversation the conversation to set
+     */
+    public void setConversation(Conversation conversation)
+    {
+        this.conversation = conversation;
+    }
+
+    /**
+     * @return the current
+     */
+    public int getCurrent()
+    {
+        return current;
+    }
+
+    /**
+     * @param current the current to set
+     */
+    public void setCurrent(int current)
+    {
+        this.current = current;
+    }
+    
+    
+
+}

Propchange: incubator/openwebbeans/trunk/samples/jsf2sample/src/main/java/org/apache/webbeans/jsf2/ConversationBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/samples/jsf2sample/src/main/java/org/apache/webbeans/jsf2/ConversationData.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/samples/jsf2sample/src/main/java/org/apache/webbeans/jsf2/ConversationData.java?rev=835495&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/samples/jsf2sample/src/main/java/org/apache/webbeans/jsf2/ConversationData.java
(added)
+++ incubator/openwebbeans/trunk/samples/jsf2sample/src/main/java/org/apache/webbeans/jsf2/ConversationData.java
Thu Nov 12 18:42:32 2009
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You 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.webbeans.jsf2;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.ConversationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+@ConversationScoped
+public class ConversationData implements Serializable
+{
+    private static final long serialVersionUID = 1L;
+    
+    private int i = 0;
+    
+    @Inject
+    public ConversationData()
+    {
+        i = 10;
+    }
+    
+    @Produces @Named("mynumber")
+    public int getNumber()
+    {
+        return i++;
+    }
+}

Propchange: incubator/openwebbeans/trunk/samples/jsf2sample/src/main/java/org/apache/webbeans/jsf2/ConversationData.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/samples/jsf2sample/src/main/webapp/conversation.xhtml
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/samples/jsf2sample/src/main/webapp/conversation.xhtml?rev=835495&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/samples/jsf2sample/src/main/webapp/conversation.xhtml (added)
+++ incubator/openwebbeans/trunk/samples/jsf2sample/src/main/webapp/conversation.xhtml Thu
Nov 12 18:42:32 2009
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
+<!--
+	
+	Licensed to the Apache Software Foundation (ASF) under one or more
+	contributor license agreements. See the NOTICE file distributed with
+	this work for additional information regarding copyright ownership.
+	The ASF licenses this file to You 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 xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html">
+<h:head>
+	<title>JSF2 Ajax with OpenWebBeans Demo</title>
+</h:head>
+<h:body>
+	
+	<div>
+	<h3>JSF2 Conversation Demo</h3>
+	<p>
+		Number will be increased each time user press <b>Show Number</b> button if
conversation is in progress. Initial number set to <b>10</b>
+	</p>
+	</div>
+	
+	<ul>
+	<li><h4>Click <b style="color: red;">Start Conversation</b> to start
conversation </h4></li>
+	<li><h4>Click <b style="color: red;">End Conversation</b> to end
conversation </h4></li>
+	<li><h4>Click <b style="color: red;">Show Number</b> to show number
in the current conversation </h4></li>
+	</ul>
+
+	<h:form id="form">
+		
+		<h:outputScript name="jsf.js" library="javax.faces" target="body"></h:outputScript>
	
+		
+		<div>		
+			<h:outputText value="Current Number  : " style="color:red;"/>
+			<h:outputText value="#{conversationBean.current}" id="status" style="font-weight:bold;"
/>
+		</div>
+
+		<div style="margin-top: 10px;">
+			<h:outputText value="#{conversationBean.message}" id="message" style="font-weight:bold;"
/>			
+		</div>		
+			
+		<div style="margin-top: 10px;">
+			<h:commandButton id="button1" value="Start Conversation" actionListener="#{conversationBean.startConversation}"
+			    onclick="jsf.ajax.request(this,event, {execute:'form:button1',render:'form:message
form:status'});return false;">
+			</h:commandButton>
+			
+			<h:commandButton id="button2" value="End Conversation" actionListener="#{conversationBean.stopConversation}"
+			    onclick="jsf.ajax.request(this,event, {execute:'form:button2',render:'form:message
form:status'});return false;">
+			</h:commandButton>
+			
+			<h:commandButton id="button3" value="Show Number"
+			    onclick="jsf.ajax.request(this,event, {execute:'form:button3',render:'form:status'});return
false;">
+			</h:commandButton>							
+		</div>
+				
+	</h:form>
+
+</h:body>
+</html>
\ No newline at end of file

Propchange: incubator/openwebbeans/trunk/samples/jsf2sample/src/main/webapp/conversation.xhtml
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message