Thread: The Java Bean ?
View Single Post
Old 04-23-2004, 05:32 PM   #6 (permalink)
technobard
Centurion Nova Prime
 
technobard's Avatar
 
Join Date: May 2002
Location: Oak Park, IL (USA)
Posts: 285
technobard is on a distinguished road
A little more info:
The bean specification examines the class and expects certain naming conventions to figure out which properties are available, etc.

Your class should look something like:
Code:
public class User {
    String username="";
    Strimg email="";

    public User() {
    }

    public String getUsername() {
       return username;
    }

    public void setUsername(String username) {
       this.username = username;
    }

    public String getEmail() {
       return email;
    }

    public void setEmail(String email) {
       this.email = email;
    }
}
If I remember correctly, the getter and setter methods must be named by using the prefixes "get" and "set" followed by the variable name with the first letter capitalized.
technobard is offline   Reply With Quote