MikeB schrieb:> Reading about JSPs and came across a sentence that says "A JavaBean
must contain get and set methods for all of the properties that need
to be accessed by JSPs. In this example, the methods provide access to
all of the instance variables of the class, which represent the
properties, so this class qualify as a bean. Of course, you can also
code get and set methods that provide access to other properties in a
bean."
So now I'm confused. Are instance variables properties?
No, not in general.
Can some instance variables not be properties?
Yes, you can make an instance variable into a property:
Suppose you have a class with the instance variable
private int xyz;
You can add these 2 methods to your class:
public int getBla() {
return xyz;
}
public void setBla(int n) {
xyz = n;
}
Now your class has a property with name "bla" (not "xyz") and type "int".
What, other than instance variables, can be properties?
Anything, as long as there is a pair of get/set methods.
I tried googling on "Java Properties", but came up with a zillion hits
on the java.util.Properties class. So is this somehow related to the
use of "properties" in the quoted paragraph?
No, the "java.util.Properties" class is a different thing.
Your properties are the ones from package "java.beans".
For more info seehttp://java.sun.com/j2se/1.4.2/docs/api/java/beans/package-summary.htmlhttp://java.sun.com/docs/books/tutorial/javabeans/
--
Thomas
Thank you, that clarified it for me. I'll read up on the links you