class Cat{
}
class Tiger extends Cat{
public String getZooAddress(){
return "cityZoo";
};
}
Bean{
public Cat getCat() {
return new Tiger();
}
}
I noticed that #{bean.cat.zooAddress} actually displays “cityZoo”. How does it work? I imagined that #{bean.cat} represents a Cat and trying to call getZooAddress() would result in an “property not found” error. Is the container automatically doing the downcasting from Cat to Tiger?
Expression Language utilizes Reflection to find the appropriate property accessor methods on the referenced object.
Here is more information on why Expression Language happens to work this way.
http://today.java.net/pub/a/today/2006/03/07/unified-jsp-jsf-expression-language.html#evaluation-of-el