• Post Reply Bookmark Topic Watch Topic
  • New Topic

Rendered attribute and Expression Language

 
Marcin Kwiatkowski
Ranch Hand
Posts: 32
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
I've something like this:

<h:dataTable value="#{SomeBean.someList}" var="List">
<h:column>
<hutputText value="some text" rendered="..."></hutputText>
</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?
 
A. Dusi
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This should be
 
gul kaur
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can't use < for comparing two values use le(less than equal)"#{value1 le value2}"
 
Tim Holloway
Bartender
Posts: 18414
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!