• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

EL: Concatenation of property name

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 200
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.)
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic