• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Rendered attribute and Expression Language

 
Ranch Hand
Posts: 32
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
I've something like this:

<h:dataTable value="#{SomeBean.someList}" var="List">
<h:column>
<h:outputText value="some text" rendered="..."></h:outputText>
</h:column>
</h:dataTable>

I need to compare two values one from 'List' and one from 'SomeBean'. I tried something like this: rendered="#{List.value} < #{SomeBean.value}", but it didn't work. Is there any way to compare these two values by EL?
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


This should be
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can't use < for comparing two values use le(less than equal)"#{value1 le value2}"
 
Saloon Keeper
Posts: 25477
180
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
Actually, I think you can, but you have to use the entity version of the less-than operator so that the XML parser doesn't mistake it for part of an element definition.

In other words, not:

rendered="#{a < b}"

but:

rendered="#{a &lt; b}"

But having said that, I really don't recommend doing any sort of logic on the web page itself unless it's unavoidable. I normally use a boolean property in the backing bean or a formatter in the backing bean.
 
please buy this thing and then I get a fat cut of the action:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic