0

I have a simple question, got stucked on this for a few hours now...

#{bean.testVar eq 'AAA'}
<c:choose>
  <c:when test="#{bean.testVar eq 'AAA'}">
   TRUE
  </c:when>
  <c:otherwise>
   FALSE
  </c:otherwise>
</c:choose>

testVar is returning String "AAA", but on page I always see

true
FALSE

when I expect

true 
TRUE

Any ideas what might be causing this? Thanks.

BalusC
  • 1,040,783
  • 362
  • 3,548
  • 3,513
Gatekeeper
  • 1,566
  • 3
  • 21
  • 33
  • In future JSF/Facelets related questions please explicitly tag them. It's a world of difference as compared to legacy JSP which is otherwise assumed in JSTL-only questions. – BalusC Sep 11 '13 at 14:02
  • 1
    Before answering your quesiton, please show how you initialize `testVar`. The symptoms indicate that it isn't initialized during JSF view build time, but only during JSF view render time. In the meanwhile, prepare yourself by reading http://stackoverflow.com/questions/3342984/jstl-in-jsf2-facelets-makes-sense – BalusC Sep 11 '13 at 14:04
  • testVar is initialized on backend by calling standard setter method on bean object... – Gatekeeper Sep 11 '13 at 14:12
  • Yes sure. I wasn't asking for the obvious. Please be more specific. Who's calling that setter? A `` or `` or so? – BalusC Sep 11 '13 at 14:17
  • No, I just send a request to backend and it gets loaded from DB there, dont know the actual code for this. – Gatekeeper Sep 11 '13 at 14:28
  • Well, then no one can post a constructive answer explaining how exactly this problem is caused and how you can solve it so that you can keep using ``. I can at least tell how you can workaround it: use JSF component's `rendered` attribute instead. Perhaps this workaround is after all actually the solution and you was wrongly using `` from the beginning on. – BalusC Sep 11 '13 at 14:51
  • Whats important on how the data is initialized? In the end its just String property on bean object, I dont see any connection there. Just asking, obviously I am no expert in this :-) – Gatekeeper Sep 11 '13 at 14:56
  • Apparently you didn't read (or understood) the link in my 1st comment. Sorry, then it stops here. Please read it and then we can continue. – BalusC Sep 11 '13 at 14:57
  • Yes you are right, I am starting to get it now. I will take some time later to read more about this, but anyway thanks for the workaround which works fine for now. And for the patience :-) – Gatekeeper Sep 11 '13 at 15:07
  • The usual mistake when using jstl in JSF is when you use jstl tags insde jsf iterations. You should understand that jstl tags are handlers in JSF, not components and are executed during the build of component tree. It is important where you put jstl tags. Can you post full page where you was trying to use this? – trims Sep 12 '13 at 12:41

0 Answers0