User.java - the Backing Bean
The backing bean is a very simple java class. It has no constructor which defaults to a constructor with no parameters and it has setters and getters for each property. (Note: JSF likes to have both methods available even though the spec says you can have a property with just a setter or just a getter.)
package com.corejsf;
import java.util.*;
public class UserBean {
private String name;
private String password;
private String city;
private String zip;
private int javaYear;
private java.util.Date dob;
// PROPERTY: name
public String getName() { return name; }
public void setName(String newValue) { name = newValue; }
// PROPERTY: password
public String getPassword() { return password; }
public void setPassword(String newValue) { password = newValue; }
// PROPERTY city
public String getCity() { return city; }
public void setCity(String newValue) { city = newValue; }
// PROPERTY zip
public String getZip() { return zip; }
public void setZip(String newValue) { zip = newValue; }
// PROPERTY javaYear
public int getJavaYear() { return javaYear; }
public void setJavaYear(int newValue) { javaYear = newValue; }
// PROPERTY dob
public java.util.Date getDob() { return dob; }
public void setDob(java.util.Date newValue) { dob = newValue; }
There are two methods at the bottom that we will cover later.