Re: Definition of a "property"
- From: Thomas Fritsch <i.dont.like.spam@xxxxxxxxxxx>
- Date: Sat, 28 Apr 2007 16:55:21 +0200
MikeB schrieb:
Reading about JSPs and came across a sentence that says "A JavaBeanNo, not in general.
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?
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.
No, the "java.util.Properties" class is a different thing.
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?
Your properties are the ones from package "java.beans".
For more info see
http://java.sun.com/j2se/1.4.2/docs/api/java/beans/package-summary.html
http://java.sun.com/docs/books/tutorial/javabeans/
--
Thomas
.
- Follow-Ups:
- Re: Definition of a "property"
- From: MikeB
- Re: Definition of a "property"
- References:
- Definition of a "property"
- From: MikeB
- Definition of a "property"
- Prev by Date: Re: How to convert a string to an object reference?
- Next by Date: Re: How to convert a string to an object reference?
- Previous by thread: Re: Definition of a "property"
- Next by thread: Re: Definition of a "property"
- Index(es):
Relevant Pages
|
|