-
October 1st, 2004, 02:45 PM
#1
Senior Member
JavaBeans
Hello guys,
I am new to Java World.
I want to know what are JavaBeans and how can we use them with basic Java.
Like I want to know how do we make a JavaBean Objects.
Answers and References will be appricated.
Thanx
U get What U pay for.
-
October 2nd, 2004, 04:38 AM
#2
A mind full of questions has no room for answers
-
October 11th, 2004, 09:40 PM
#3
Member
The easiest way to describe a java bean is that it is a class file that has a bunch of fields i.e. private int foo and then it has getter and setter methods to access these private fields, this would be something like public int getFoo() { return foo; } and public void setFoo (int foo) { this.foo = foo; } and they would be there for all of the fields.
-BigDick
--BigDick
\"When in Rome, eat Rome!\" -Godzilla
-
October 13th, 2004, 04:16 PM
#4
Senior Member
Thanx a lot BigDick.
It would be really kind of you if you coulld explain a bit more, I am interested in exactly what u r talking about, but i would like to have some more information about this.
like i have the following class:
----------
class MBFFEE
{
private int foo;
private String Type;
}
--------------
now my problem is that i am new to all this i am not understanding where and how will setfoo() and getfoo() will be used, and how will they be defined.
I will be really greatfull to you if u could help me.
One more this, is there any data type like int, string that can store date.
Regards
Harbir
U get What U pay for.
-
October 13th, 2004, 04:55 PM
#5
Getters/Setters are used to expose access to private member variables.
Here's an example of a getter/setter for foo in your class above:
Code:
public int getFoo()
{
return this.foo;
}
public void setFoo(int newfoo)
{
this.foo = newfoo;
}
The primary use of getters and setters is data validation.
A Java bean is well more than a simple struct-style element. It is really meant to allow you to write a piece of code once, and run it everywhere (applets, desktop apps, JSP, etc). Basically let's say you have a class that deals with outputting customer data. You might have this class written once but be using it on your secured site via JSP, in a desktop Java app, or in a Java applet served from the web.
The FAQ for Java Beans is here: http://java.sun.com/products/javabea...q.general.html
Chris Shepherd
The Nelson-Shepherd cutoff: The point at which you realise someone is an idiot while trying to help them.
\"Well as far as the spelling, I speak fluently both your native languages. Do you even can try spell mine ?\" -- Failed Insult
Is your whole family retarded, or did they just catch it from you?
-
October 13th, 2004, 05:02 PM
#6
A better term than getters/setters is accessors (getters) or mutators (setters). And a java bean is not a struct. It may be better to compare then to a com component.
"When I get a little money I buy books; and if any is left I buy food and clothes." - Erasmus
"There is no programming language, no matter how structured, that will prevent programmers from writing bad programs." - L. Flon
"Mischief my ass, you are an unethical moron." - chsh
Blog of X
-
October 19th, 2004, 09:58 AM
#7
Senior Member
Thanks guys.
Actually i am sorry for not thanking earlier.
But the help you guys offered was really helpfull, it did solve the purpose.
Regards
Harbir
U get What U pay for.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|