• Post Reply Bookmark Topic Watch Topic
  • New Topic

EL: Concatenation of property name

 
Paolo Pinkel
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I concatenate the name of a property using the EL?

This is what I tried:



But it didn't work.

The bean has the four property resultA, resultB, resultC and resultD. getParts() returns "A", "B", "C", and "D".

Any idea how I can achieve that?
 
Guy deLyonesse
Ranch Hand
Posts: 200
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure which version of JSF you're using but either way you need to lose the () and call it by the member, not the getter method. The EL will automatically go for the getter.



 
Paolo Pinkel
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't have the source code on this notebook, but the ui:repeat-part seemed to work fine, it was the concatenation that didn't work. Do you see anything wrong there?

I called "getParts()" because it isn't a property in sense of having a getter and setter. It was just a method that provides me a list. (Which is always the same anyway.)
 
Tim Holloway
Bartender
Posts: 18417
60
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Facelets is not a programming language, and EL is not a scripting language. It violates the whole purpose of MVC when you put code in the View. Might as well use a chainsaw to butter your scones.

The ui:repeat construct gets overused by people who seem to think they're gaining something by not using one of the graphically-oriented JSF table tags. There's a definite place for ui:repeat, but please use the right tool for the job.

Your EL is expecting JSF to evaluate 2 separate EL expressions and then evaluate the results of that expression. You'd need an extra layer of "#{}" to indicate that, but I don't think nested EL is supported, since as I said, the purpose of EL is not to be a scripting language.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!