[webbeans-commits] Webbeans SVN: r2219 - in examples/trunk: jsf2 and 11 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Thu Mar 26 14:06:38 EDT 2009
Author: pete.muir at jboss.org
Date: 2009-03-26 14:06:38 -0400 (Thu, 26 Mar 2009)
New Revision: 2219
Added:
examples/trunk/jsf2/
examples/trunk/jsf2/WebContent/
examples/trunk/jsf2/WebContent/WEB-INF/
examples/trunk/jsf2/WebContent/WEB-INF/beans.xml
examples/trunk/jsf2/WebContent/WEB-INF/faces-config.xml
examples/trunk/jsf2/WebContent/WEB-INF/web.xml
examples/trunk/jsf2/WebContent/home.xhtml
examples/trunk/jsf2/WebContent/index.html
examples/trunk/jsf2/WebContent/style/
examples/trunk/jsf2/WebContent/template.xhtml
examples/trunk/jsf2/build.xml
examples/trunk/jsf2/pom.xml
examples/trunk/jsf2/src/
examples/trunk/jsf2/src/main/
examples/trunk/jsf2/src/main/java/
examples/trunk/jsf2/src/main/java/org/
examples/trunk/jsf2/src/main/java/org/jboss/
examples/trunk/jsf2/src/main/java/org/jboss/webbeans/
examples/trunk/jsf2/src/main/java/org/jboss/webbeans/examples/
examples/trunk/jsf2/src/main/java/org/jboss/webbeans/examples/numberguess/
examples/trunk/jsf2/src/main/java/org/jboss/webbeans/examples/numberguess/Game.java
examples/trunk/jsf2/src/main/java/org/jboss/webbeans/examples/numberguess/Generator.java
examples/trunk/jsf2/src/main/java/org/jboss/webbeans/examples/numberguess/MaxNumber.java
examples/trunk/jsf2/src/main/java/org/jboss/webbeans/examples/numberguess/Random.java
examples/trunk/jsf2/src/main/resources/
examples/trunk/jsf2/src/main/resources/META-INF/
Modified:
examples/trunk/pom.xml
Log:
add jsf2 example stub
Property changes on: examples/trunk/jsf2
___________________________________________________________________
Name: svn:ignore
+ .classpath
target
.project
.settings
pom.xml.releaseBackup
Added: examples/trunk/jsf2/WebContent/WEB-INF/beans.xml
===================================================================
Added: examples/trunk/jsf2/WebContent/WEB-INF/faces-config.xml
===================================================================
--- examples/trunk/jsf2/WebContent/WEB-INF/faces-config.xml (rev 0)
+++ examples/trunk/jsf2/WebContent/WEB-INF/faces-config.xml 2009-03-26 18:06:38 UTC (rev 2219)
@@ -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>
Added: examples/trunk/jsf2/WebContent/WEB-INF/web.xml
===================================================================
--- examples/trunk/jsf2/WebContent/WEB-INF/web.xml (rev 0)
+++ examples/trunk/jsf2/WebContent/WEB-INF/web.xml 2009-03-26 18:06:38 UTC (rev 2219)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app version="2.5"
+ 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-app_2_5.xsd">
+
+ <display-name>Web Beans Numberguess example</display-name>
+
+ <!-- JSF -->
+
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <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>
+ </session-config>
+
+</web-app>
Added: examples/trunk/jsf2/WebContent/home.xhtml
===================================================================
--- examples/trunk/jsf2/WebContent/home.xhtml (rev 0)
+++ examples/trunk/jsf2/WebContent/home.xhtml 2009-03-26 18:06:38 UTC (rev 2219)
@@ -0,0 +1,34 @@
+<!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">
+ <h1>Guess a number...</h1>
+ <h:form id="NumberGuessMain">
+ <div style="color: red">
+ <h:messages id="messages" globalOnly="false"/>
+ <h:outputText id="Higher" value="Higher!" rendered="#{game.number gt game.guess and game.guess ne 0}"/>
+ <h:outputText id="Lower" value="Lower!" rendered="#{game.number lt game.guess and game.guess ne 0}"/>
+ </div>
+
+ <div>
+ I'm thinking of a number between #{game.smallest} and #{game.biggest}. You have #{game.remainingGuesses} guesses.
+ </div>
+
+ <div>
+ Your guess:
+ <h:inputText id="inputGuess" value="#{game.guess}" required="true" size="3" disabled="#{game.number eq game.guess}">
+ <f:validateLongRange maximum="#{game.biggest}" minimum="#{game.smallest}"/>
+ </h:inputText>
+ <h:commandButton id="GuessButton" value="Guess" action="#{game.check}" disabled="#{game.number eq game.guess}"/>
+ </div>
+ <div>
+ <h:commandButton id="RestartButton" value="Reset" action="#{game.reset}" immediate="true" />
+ </div>
+ </h:form>
+ </ui:define>
+ </ui:composition>
+</html>
Added: examples/trunk/jsf2/WebContent/index.html
===================================================================
--- examples/trunk/jsf2/WebContent/index.html (rev 0)
+++ examples/trunk/jsf2/WebContent/index.html 2009-03-26 18:06:38 UTC (rev 2219)
@@ -0,0 +1,5 @@
+<html>
+<head>
+ <meta http-equiv="Refresh" content="0; URL=home.jsf">
+</head>
+</html>
\ No newline at end of file
Added: examples/trunk/jsf2/WebContent/template.xhtml
===================================================================
--- examples/trunk/jsf2/WebContent/template.xhtml (rev 0)
+++ examples/trunk/jsf2/WebContent/template.xhtml 2009-03-26 18:06:38 UTC (rev 2219)
@@ -0,0 +1,34 @@
+<!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">
+
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+ <title>Numberguess</title>
+ <link href="style/main.css" rel="stylesheet" type="text/css"/>
+ <ui:insert name="head"/>
+</head>
+
+<body>
+
+ <div id="container">
+ <div id="header">
+
+ </div>
+
+ <div id="sidebar">
+
+ </div>
+
+ <div id="content">
+ <ui:insert name="content"/>
+ </div>
+
+ <br style="clear:both"/>
+ </div>
+
+</body>
+</html>
+
Added: examples/trunk/jsf2/build.xml
===================================================================
--- examples/trunk/jsf2/build.xml (rev 0)
+++ examples/trunk/jsf2/build.xml 2009-03-26 18:06:38 UTC (rev 2219)
@@ -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
Added: examples/trunk/jsf2/pom.xml
===================================================================
--- examples/trunk/jsf2/pom.xml (rev 0)
+++ examples/trunk/jsf2/pom.xml 2009-03-26 18:06:38 UTC (rev 2219)
@@ -0,0 +1,84 @@
+<?xml version="1.0"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.jboss.webbeans.examples</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.jboss.webbeans.examples</groupId>
+ <artifactId>webbeans-numberguess-jsf2</artifactId>
+ <packaging>war</packaging>
+ <name>Web Beans Examples: Numberguess for JSF2</name>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>codehaus snapshot repository</id>
+ <url>http://snapshots.repository.codehaus.org/</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ <classifier>jdk15</classifier>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.webbeans</groupId>
+ <artifactId>jsr299-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.facelets</groupId>
+ <artifactId>jsf-facelets</artifactId>
+ </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>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>webbeans-numberguess-jsf2</finalName>
+ </build>
+
+</project>
+
Added: examples/trunk/jsf2/src/main/java/org/jboss/webbeans/examples/numberguess/Game.java
===================================================================
--- examples/trunk/jsf2/src/main/java/org/jboss/webbeans/examples/numberguess/Game.java (rev 0)
+++ examples/trunk/jsf2/src/main/java/org/jboss/webbeans/examples/numberguess/Game.java 2009-03-26 18:06:38 UTC (rev 2219)
@@ -0,0 +1,94 @@
+package org.jboss.webbeans.examples.numberguess;
+
+
+import java.io.Serializable;
+
+import javax.annotation.Named;
+import javax.annotation.PostConstruct;
+import javax.context.SessionScoped;
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+import javax.inject.AnnotationLiteral;
+import javax.inject.Current;
+import javax.inject.manager.Manager;
+
+ at Named
+ at SessionScoped
+public class Game implements Serializable
+{
+ private int number;
+
+ private int guess;
+ private int smallest;
+
+ @MaxNumber
+ private int maxNumber;
+
+ private int biggest;
+ private int remainingGuesses;
+
+ @Current Manager manager;
+
+ public Game()
+ {
+ }
+
+ 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() throws InterruptedException
+ {
+ 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;
+ }
+
+ @PostConstruct
+ public void reset()
+ {
+ this.smallest = 0;
+ this.guess = 0;
+ this.remainingGuesses = 10;
+ this.biggest = maxNumber;
+ this.number = manager.getInstanceByType(Integer.class, new AnnotationLiteral<Random>(){});
+ }
+
+}
Added: examples/trunk/jsf2/src/main/java/org/jboss/webbeans/examples/numberguess/Generator.java
===================================================================
--- examples/trunk/jsf2/src/main/java/org/jboss/webbeans/examples/numberguess/Generator.java (rev 0)
+++ examples/trunk/jsf2/src/main/java/org/jboss/webbeans/examples/numberguess/Generator.java 2009-03-26 18:06:38 UTC (rev 2219)
@@ -0,0 +1,33 @@
+package org.jboss.webbeans.examples.numberguess;
+
+
+import java.io.Serializable;
+
+import javax.context.ApplicationScoped;
+import javax.inject.Produces;
+
+ at ApplicationScoped
+public class Generator implements Serializable
+{
+
+ private static final long serialVersionUID = -7213673465118041882L;
+
+ 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;
+ }
+
+}
Added: examples/trunk/jsf2/src/main/java/org/jboss/webbeans/examples/numberguess/MaxNumber.java
===================================================================
--- examples/trunk/jsf2/src/main/java/org/jboss/webbeans/examples/numberguess/MaxNumber.java (rev 0)
+++ examples/trunk/jsf2/src/main/java/org/jboss/webbeans/examples/numberguess/MaxNumber.java 2009-03-26 18:06:38 UTC (rev 2219)
@@ -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.inject.BindingType;
+
+ at Target( { TYPE, METHOD, PARAMETER, FIELD })
+ at Retention(RUNTIME)
+ at Documented
+ at BindingType
+public @interface MaxNumber
+{
+
+}
Added: examples/trunk/jsf2/src/main/java/org/jboss/webbeans/examples/numberguess/Random.java
===================================================================
--- examples/trunk/jsf2/src/main/java/org/jboss/webbeans/examples/numberguess/Random.java (rev 0)
+++ examples/trunk/jsf2/src/main/java/org/jboss/webbeans/examples/numberguess/Random.java 2009-03-26 18:06:38 UTC (rev 2219)
@@ -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.inject.BindingType;
+
+ at Target( { TYPE, METHOD, PARAMETER, FIELD })
+ at Retention(RUNTIME)
+ at Documented
+ at BindingType
+public @interface Random
+{
+
+}
Modified: examples/trunk/pom.xml
===================================================================
--- examples/trunk/pom.xml 2009-03-26 17:36:33 UTC (rev 2218)
+++ examples/trunk/pom.xml 2009-03-26 18:06:38 UTC (rev 2219)
@@ -46,6 +46,7 @@
<modules>
<module>numberguess</module>
+ <module>jsf2</module>
<module>translator</module>
<module>login</module>
<module>conversations</module>
More information about the weld-commits
mailing list