This may come across as a naive question. I blame my inexperience in Java Beans.
Im using Java Beans as follows --
I have a class ComponentModel
which has a boolean
member isComponentEditable
Then i have a ComponentPropertyEditor
class wherein i do the following --
public ComponentPropertyEditorModel(ComponentModel bean) {
BeanInfo info = Introspector.getBeanInfo(bean.getClass());
PropertyDescriptor[] props = info.getPropertyDescriptors();
for (PropertyDescriptor prop : props)
System.out.println(prop.getName());
}
Im seeing that getName()
for my aforementioned member isComponentEditable
is being returned as componentAsEditable
. I was under the impression that for classes the member names would be returned as is in getName()
.
The javadoc says that getName()
returns 'the programmatic name'.
What is programmatic name and why is it different from the name of my aforementioned class member ?
The name of a JavaBean property accessed by getFoo()
or isFoo()
is "foo". If you want the accessor method, (isFoo()
), you should call getReadMethod()
.
It's the programmatic name in the sense that it's the name you will use when firing events when the property changes, for example, or the name you will use when accessing the property using a scripting language like Groovy or the JSP EL:
<c:out value="${bean.componentEditable}"/>
See http://docs.oracle.com/javase/tutorial/javabeans/writing/properties.html for more information.