I have following two simple POJOs:
class Person {
String name
Address address;
//and of course the getter/setter for the attributes
}
class Address
Nested bean properties in a brace notation string expression like #{person['address.city']}
is by default not supported. You basically need a #{person['address']['city']}
.
You need a custom ELResolver
here. Easiest is to extend the existing BeanELResolver.
Here's a kickoff example:
public class ExtendedBeanELResolver extends BeanELResolver {
@Override
public Object getValue(ELContext context, Object base, Object property)
throws NullPointerException, PropertyNotFoundException, ELException
{
if (property == null || base == null || base instanceof ResourceBundle || base instanceof Map || base instanceof Collection) {
return null;
}
String propertyString = property.toString();
if (propertyString.contains(".")) {
Object value = base;
for (String propertyPart : propertyString.split("\\.")) {
value = super.getValue(context, value, propertyPart);
}
return value;
}
else {
return super.getValue(context, base, property);
}
}
}
To get it to run, register it as follows in faces-config.xml
:
com.example.ExtendedBeanELResolver