Java EE 7 SDK |
This sample application demonstrates how to use CDI (Contexts and Dependency Injection) with JavaServer Faces.
This sample application gives you 10 attempts to guess a number between 1 an 100. After each attempt, the application tells you whether your guess was too high or too low.
The example consists of two qualifiers, an application scopped bean, and a session-scoped bean:
@Random
qualifier injects a random number.@MaxNumber
qualifier injects the maximum number allowed.Generator
bean generates a random number and the maximum number using producer methods.Game
bean sets up or resets the game, captures and validates the user's guess, and provides feedback with a FacesMessage
. This bean
is the primary entry point of the application.Perform the following steps to build, deploy, and run the application:
app_dir
is the sample application base directory: samples_install_dir/javaee7/cdi/cdi-guess
.app_dir.
run
outcome.
mvn clean verify cargo:run
clean
outcome to undeploy the sample application and to remove the temporary directories such as build
and dist
.
mvn clean
If you have problems when running the application, refer to the troubleshooting document.
Copyright © 1997-2013 Oracle and/or its affiliates. All rights reserved.