Double evaluation for an expression
Hello,
I'm trying to make an expression work in my jsf. Maybe I'm doing wrong...
I need to access a property within a bean (ex: property name on bean person). That seems quite simple with #{myPerson.name}
. Ok
But I want the "name" attribute to be itself the result of an evaluation.. Is it possible to have something like #{myPerson}.#{attribute}
with attribute containig the value "name"?
I've tried many odd things like #{myPerson[attribute]}
and so on ....
Any suggestion will be greatly appreciated.
TIA
Harry Co
[797 byte] By [
ddansoua] at [2007-10-2 16:28:47]

> create a method in the bean that do that for you.
Thanks puigi,
yes of course, that's possible... But I thought something more script-like exists...
If I have to make it done by a bean, some I'm not really generic. It's strange that we can't do a "simple" script based double eval...
In fact, I want to do something really generic.
I have a modelHelper class that defines displayable attributes of a bean. And then by iterating this model, I get attributes id. So if there where a typical expression for indirectly getting the attribute value within the bean, it would be really great.
Hope I'm clear enough
Harry Co
I've tried #{aPerson[attrib]}
successfully with a simple type attribute.
ex : attrib containing name results in "John" the correct value for aPerson.getName() when name is John.
But when attrib is compound (ex : adress.city), I failed on getting work..
I expected it to work like aPerson.getAdress().getCity() just like a org.apache.commans.beanutils.BeanUtils
would act!
Any idea?
TIA
Harry Co