Skip to main content


Showing posts from August, 2012

Guessing Game Implementation using JSF

In a typical Java Server Faces application each page connect to a managed bean, that have properties and methods that are associated with the components. This Guessing Game application consists of one managed bean and two views. All views are using same bean.  The following are requirements for this application. 1. User must enter a number from 0 to 10.
2. Maximum number of attempt is 5.
3. If user guess a correct number with in 5 attempts, the success message is displayed to the user otherwise the failure message is displayed.  Ok let's create a managed bean for implementing above requirements. package com.pointerunits; import; import java.util.Random; import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped; import javax.faces.context.FacesContext; @ManagedBean @SessionScoped public class GuessingGame { private int randomNumber; private int userNumber; private int minimum; private int maximum; private int allowableAttempts; pr…