j2ee: JavaBean basics [16/20] Previous pageContentsNext page

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:

These conventions will have to be followed to use Beans in JSPs properly

Previous pageContentsNext page