Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Use of JavaBeans

 
Balachandar Nayak
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all

Im learning J2EE and Im a beginner
What is JavaBean?
What is the use of the getter and setter functions
described in the Bean?
How it is used to transfer data from a GUI and a database?
Kindly response to my question.

Thanks in Advance

Regards
bala
 
S Venkatesh
Ranch Hand
Posts: 464
Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai,
You can consider the javabean as a simple java class.It can be described with the follwoing elements.
1. All the variables in this class are private variables.
2. All these variables have corresponding getter and setter methods.
3. It may also contain a equals(object obj) method.

Ex: (I have not compiled the class)
public class Login{
String userName;
String password;
public void setUserName(String userName){
this.userName = userName;
}
public String getUserName(){
return this.userName;
}
public void setPassword(String password){
this.password = password;
}
public String getPassword(){
return this.password;
}
public boolean equals(Object obj) {
//you can check if the obj elements matches your bean elements
//and return true otherwise return false
}
}

Regards
Venkatesh S
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic