Author: pete.muir(a)jboss.org
Date: 2008-12-24 10:41:58 -0500 (Wed, 24 Dec 2008)
New Revision: 697
Modified:
ri/trunk/examples/numberguess/WebContent/home.xhtml
ri/trunk/examples/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/Game.java
Log:
WBRI-74, WBRI-77, WBRI-73
Modified: ri/trunk/examples/numberguess/WebContent/home.xhtml
===================================================================
--- ri/trunk/examples/numberguess/WebContent/home.xhtml 2008-12-24 10:29:43 UTC (rev 696)
+++ ri/trunk/examples/numberguess/WebContent/home.xhtml 2008-12-24 15:41:58 UTC (rev 697)
@@ -11,8 +11,8 @@
<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}"/>
- <h:outputText id="Lower" value="Lower!"
rendered="#{game.number lt game.guess}"/>
+ <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>
@@ -26,6 +26,9 @@
</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>
Modified:
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 2008-12-24
10:29:43 UTC (rev 696)
+++
ri/trunk/examples/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/Game.java 2008-12-24
15:41:58 UTC (rev 697)
@@ -1,11 +1,15 @@
package org.jboss.webbeans.examples.numberguess;
+import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
+import javax.webbeans.AnnotationLiteral;
+import javax.webbeans.Current;
import javax.webbeans.Initializer;
import javax.webbeans.Named;
import javax.webbeans.SessionScoped;
+import javax.webbeans.manager.Manager;
@Named
@SessionScoped
@@ -18,17 +22,16 @@
private int biggest;
private int remainingGuesses;
+ @Current Manager manager;
+
public Game()
{
}
@Initializer
- Game(@Random int number, @MaxNumber int maxNumber)
- {
- this.number = number;
- this.smallest = 1;
+ Game(@MaxNumber int maxNumber)
+ {
this.biggest = maxNumber;
- this.remainingGuesses = 10;
}
public int getNumber()
@@ -79,4 +82,13 @@
return null;
}
+ @PostConstruct
+ public void reset()
+ {
+ this.smallest = 0;
+ this.guess = 0;
+ this.remainingGuesses = 10;
+ this.number = manager.getInstanceByType(Integer.class, new
AnnotationLiteral<Random>(){});
+ }
+
}
Show replies by date