j2ee: JavaBean basics [16/20] ![]() ![]() ![]() |
Need a zero argument constructor
All fields should be private with Accessors for public access to variables
Type value; public Type getValue() { return value; } public void setValue(Type value) { this.value = value; }
boolean value; public boolean isValue() { return value; } public void setValue(boolean value) { this.value = value; }
Type[] value; public Type[] getValue() { return value; } public void setValue(Type value[]) { this.value = value; } public Type getValue(int i) { return value[i]; } public void setValue(int i, Type v) { value[i] = v; }
Property names begin with lower case
Property names are capitilized in the getter/setter methods
Acronyms are in all CAPS
Examples:
foo getFoo(), setFoo()
fooBar getFooBar(), setFooBar()
URL getURL(), setURL()
These conventions will have to be followed to use Beans in JSPs properly