[webbeans-commits] Webbeans SVN: r496 - in ri/trunk/examples/numberguess: WebContent and 8 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Tue Dec 9 09:27:56 EST 2008
Author: pete.muir at jboss.org
Date: 2008-12-09 09:27:56 -0500 (Tue, 09 Dec 2008)
New Revision: 496
Added:
ri/trunk/examples/numberguess/WebContent/WEB-INF/faces-config.xml
ri/trunk/examples/numberguess/WebContent/WEB-INF/web-beans.xml
ri/trunk/examples/numberguess/WebContent/home.xhtml
ri/trunk/examples/numberguess/build.xml
ri/trunk/examples/numberguess/src/main/java/org/
ri/trunk/examples/numberguess/src/main/java/org/jboss/
ri/trunk/examples/numberguess/src/main/java/org/jboss/webbeans/
ri/trunk/examples/numberguess/src/main/java/org/jboss/webbeans/examples/
ri/trunk/examples/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/
ri/trunk/examples/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/Game.java
ri/trunk/examples/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/Generator.java
ri/trunk/examples/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/MaxNumber.java
ri/trunk/examples/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/Random.java
Removed:
ri/trunk/examples/numberguess/WebContent/home.xhtml
ri/trunk/examples/numberguess/WebContent/style/header.png
ri/trunk/examples/numberguess/WebContent/style/main.css
ri/trunk/examples/numberguess/WebContent/style/sidebar.png
Modified:
ri/trunk/examples/numberguess/WebContent/WEB-INF/web.xml
ri/trunk/examples/numberguess/WebContent/index.html
ri/trunk/examples/numberguess/pom.xml
Log:
Lots of fixes to example
Added: ri/trunk/examples/numberguess/WebContent/WEB-INF/faces-config.xml
===================================================================
--- ri/trunk/examples/numberguess/WebContent/WEB-INF/faces-config.xml (rev 0)
+++ ri/trunk/examples/numberguess/WebContent/WEB-INF/faces-config.xml 2008-12-09 14:27:56 UTC (rev 496)
@@ -0,0 +1,11 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<faces-config version="1.2"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
+
+ <application>
+ <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
+ </application>
+
+</faces-config>
Property changes on: ri/trunk/examples/numberguess/WebContent/WEB-INF/faces-config.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/examples/numberguess/WebContent/WEB-INF/web-beans.xml
===================================================================
Property changes on: ri/trunk/examples/numberguess/WebContent/WEB-INF/web-beans.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/examples/numberguess/WebContent/WEB-INF/web.xml
===================================================================
--- ri/trunk/examples/numberguess/WebContent/WEB-INF/web.xml 2008-12-09 14:19:53 UTC (rev 495)
+++ ri/trunk/examples/numberguess/WebContent/WEB-INF/web.xml 2008-12-09 14:27:56 UTC (rev 496)
@@ -19,6 +19,11 @@
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
+
+ <context-param>
+ <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
+ <param-value>.xhtml</param-value>
+ </context-param>
<session-config>
<session-timeout>10</session-timeout>
Deleted: ri/trunk/examples/numberguess/WebContent/home.xhtml
===================================================================
--- ri/trunk/examples/numberguess/WebContent/home.xhtml 2008-12-09 14:19:53 UTC (rev 495)
+++ ri/trunk/examples/numberguess/WebContent/home.xhtml 2008-12-09 14:27:56 UTC (rev 496)
@@ -1,14 +0,0 @@
-<!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"
- xmlns:s="http://jboss.com/products/seam/taglib">
-
- <ui:composition template="template.xhtml">
- <ui:define name="content">
- A Web Beans example
- <h:outputText value="#{game.number}" />
- </ui:define>
- </ui:composition>
-</html>
\ No newline at end of file
Added: ri/trunk/examples/numberguess/WebContent/home.xhtml
===================================================================
--- ri/trunk/examples/numberguess/WebContent/home.xhtml (rev 0)
+++ ri/trunk/examples/numberguess/WebContent/home.xhtml 2008-12-09 14:27:56 UTC (rev 496)
@@ -0,0 +1,38 @@
+<!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"
+ xmlns:s="http://jboss.com/products/seam/taglib">
+
+ <ui:composition template="template.xhtml">
+ <ui:define name="content">
+ <h1>Guess a number...</h1>
+ <h:form id="NumberGuessMain">
+ <div>
+ <h:messages id="messages" globalOnly="true"/>
+ <h:outputText id="Higher" value="Higher!" rendered="#{game.number gt game.guess}"/>
+ <h:outputText id="Lower" value="Lower!" rendered="#{game.number lt game.guess}"/>
+ </div>
+
+ <div>
+ I'm thinking of a number between <h:outputText id="Smallest" value="#{game.smallest}"/> and
+ <h:outputText id="Biggest" value="#{game.biggest}"/>. You have
+ <h:outputText id="RemainingGuesses" value="#{game.remainingGuesses}"/> guesses.
+ </div>
+
+ <div>
+ Your guess:
+ <h:inputText id="inputGuess" value="#{game.guess}" required="true" size="3">
+ <f:validateLongRange maximum="#{game.biggest}" minimum="#{game.smallest}"/>
+ </h:inputText>
+ <h:commandButton id="GuessButton" value="Guess" action="#{game.check}"/>
+ </div>
+
+ <div>
+ <h:message id="message" for="inputGuess" style="color: red"/>
+ </div>
+ </h:form>
+ </ui:define>
+ </ui:composition>
+</html>
Property changes on: ri/trunk/examples/numberguess/WebContent/home.xhtml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/examples/numberguess/WebContent/index.html
===================================================================
--- ri/trunk/examples/numberguess/WebContent/index.html 2008-12-09 14:19:53 UTC (rev 495)
+++ ri/trunk/examples/numberguess/WebContent/index.html 2008-12-09 14:27:56 UTC (rev 496)
@@ -1,5 +1,5 @@
<html>
<head>
- <meta http-equiv="Refresh" content="0; URL=home.seam">
+ <meta http-equiv="Refresh" content="0; URL=home.jsf">
</head>
</html>
\ No newline at end of file
Deleted: ri/trunk/examples/numberguess/WebContent/style/header.png
===================================================================
(Binary files differ)
Deleted: ri/trunk/examples/numberguess/WebContent/style/main.css
===================================================================
--- ri/trunk/examples/numberguess/WebContent/style/main.css 2008-12-09 14:19:53 UTC (rev 495)
+++ ri/trunk/examples/numberguess/WebContent/style/main.css 2008-12-09 14:27:56 UTC (rev 496)
@@ -1,26 +0,0 @@
-body {
- margin: 0px;
- background-color: #ffffff;
-}
-
-#header {
- background: url(header.png) top left no-repeat;
- height: 116px;
-}
-
-#container {
- width: 1024px;
- background-color: #ffffff;
-}
-
-#sidebar {
- background: url(sidebar.png) top left no-repeat;
- background-color: #ffffff;
- float: left;
- width: 150px;
- height: 487px;
-}
-
-#content {
-
-}
\ No newline at end of file
Deleted: ri/trunk/examples/numberguess/WebContent/style/sidebar.png
===================================================================
(Binary files differ)
Added: ri/trunk/examples/numberguess/build.xml
===================================================================
--- ri/trunk/examples/numberguess/build.xml (rev 0)
+++ ri/trunk/examples/numberguess/build.xml 2008-12-09 14:27:56 UTC (rev 496)
@@ -0,0 +1,7 @@
+<project basedir="." name="Numberguess Example Build" default="restart">
+
+ <property name="example.name" value="webbeans-numberguess" />
+
+ <import file="../build.xml" />
+
+</project>
\ No newline at end of file
Property changes on: ri/trunk/examples/numberguess/build.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/examples/numberguess/pom.xml
===================================================================
--- ri/trunk/examples/numberguess/pom.xml 2008-12-09 14:19:53 UTC (rev 495)
+++ ri/trunk/examples/numberguess/pom.xml 2008-12-09 14:27:56 UTC (rev 496)
@@ -40,10 +40,38 @@
</dependency>
<dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
<groupId>com.sun.facelets</groupId>
<artifactId>jsf-facelets</artifactId>
- <version>1.1.15.B1</version>
</dependency>
+
+ <!-- <dependency>
+ <groupId>org.jboss.el</groupId>
+ <artifactId>jboss-el</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>-->
+
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-ri</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
</dependencies>
<build>
Added: ri/trunk/examples/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/Game.java
===================================================================
--- ri/trunk/examples/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/Game.java (rev 0)
+++ ri/trunk/examples/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/Game.java 2008-12-09 14:27:56 UTC (rev 496)
@@ -0,0 +1,78 @@
+package org.jboss.webbeans.examples.numberguess;
+
+
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+import javax.webbeans.Initializer;
+import javax.webbeans.Named;
+import javax.webbeans.SessionScoped;
+
+ at Named
+ at SessionScoped
+public class Game
+{
+ private final int number;
+
+ private int guess;
+ private int smallest;
+ private int biggest;
+ private int remainingGuesses;
+
+ @Initializer
+ Game(@Random int number, @MaxNumber int maxNumber)
+ {
+ this.number = number;
+ this.smallest = 1;
+ this.biggest = maxNumber;
+ this.remainingGuesses = 10;
+ }
+
+ public int getNumber()
+ {
+ return number;
+ }
+
+ public int getGuess()
+ {
+ return guess;
+ }
+
+ public void setGuess(int guess)
+ {
+ this.guess = guess;
+ }
+
+ public int getSmallest()
+ {
+ return smallest;
+ }
+
+ public int getBiggest()
+ {
+ return biggest;
+ }
+
+ public int getRemainingGuesses()
+ {
+ return remainingGuesses;
+ }
+
+ public String check()
+ {
+ if (guess>number)
+ {
+ biggest = guess - 1;
+ }
+ if (guess<number)
+ {
+ smallest = guess + 1;
+ }
+ if (guess == number)
+ {
+ FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Correct!"));
+ }
+ remainingGuesses--;
+ return null;
+ }
+
+}
Property changes on: ri/trunk/examples/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/Game.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/examples/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/Generator.java
===================================================================
--- ri/trunk/examples/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/Generator.java (rev 0)
+++ ri/trunk/examples/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/Generator.java 2008-12-09 14:27:56 UTC (rev 496)
@@ -0,0 +1,28 @@
+package org.jboss.webbeans.examples.numberguess;
+
+
+import javax.webbeans.ApplicationScoped;
+import javax.webbeans.Produces;
+
+ at ApplicationScoped
+public class Generator {
+
+ private java.util.Random random = new java.util.Random( System.currentTimeMillis() );
+
+ private int maxNumber = 100;
+
+ java.util.Random getRandom()
+ {
+ return random;
+ }
+
+ @Produces @Random int next() {
+ return getRandom().nextInt(maxNumber);
+ }
+
+ @Produces @MaxNumber int getMaxNumber()
+ {
+ return maxNumber;
+ }
+
+}
Property changes on: ri/trunk/examples/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/Generator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/examples/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/MaxNumber.java
===================================================================
--- ri/trunk/examples/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/MaxNumber.java (rev 0)
+++ ri/trunk/examples/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/MaxNumber.java 2008-12-09 14:27:56 UTC (rev 496)
@@ -0,0 +1,23 @@
+package org.jboss.webbeans.examples.numberguess;
+
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.BindingType;
+
+ at Target( { TYPE, METHOD, PARAMETER, FIELD })
+ at Retention(RUNTIME)
+ at Documented
+ at BindingType
+public @interface MaxNumber
+{
+
+}
Property changes on: ri/trunk/examples/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/MaxNumber.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/examples/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/Random.java
===================================================================
--- ri/trunk/examples/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/Random.java (rev 0)
+++ ri/trunk/examples/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/Random.java 2008-12-09 14:27:56 UTC (rev 496)
@@ -0,0 +1,23 @@
+package org.jboss.webbeans.examples.numberguess;
+
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.BindingType;
+
+ at Target( { TYPE, METHOD, PARAMETER, FIELD })
+ at Retention(RUNTIME)
+ at Documented
+ at BindingType
+public @interface Random
+{
+
+}
Property changes on: ri/trunk/examples/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/Random.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
More information about the weld-commits
mailing list