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]
# 1
create a method in the bean that do that for you.
pringia at 2007-7-13 17:30:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

> 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...

ddansoua at 2007-7-13 17:30:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
you are trying to access to a bean property, so why do you want to do that like you want?
pringia at 2007-7-13 17:30:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

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

ddansoua at 2007-7-13 17:30:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
does AliasBean help you?www.myfaces.orgTomahawk components.
pringia at 2007-7-13 17:30:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

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

ddansoua at 2007-7-13 17:30:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
Take a look at this http://developers.sun.com/prodtech/javatools/jscreator/reference/docs/help/jsp-jsfel/jsf_expression_language_intro.html
pringia at 2007-7-13 17:30:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...