• Post Reply Bookmark Topic Watch Topic
  • New Topic

Probably a daft question  RSS feed

 
A Harry
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but been thrown in the deep end a bit with some JSF stuff!

Can anyone please tell me how to test for a string in the following example instead of a int?

<h:graphicImage value="/images/Flag.gif" rendered="#{line.status.ID == 2}"/>

I need to check if line.status = "TEST STRING" then & only then display the image?

thanks ever so much in advance, will sit down when time & learn it properly!
 
Shailesh Kini
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Harry,

You could use jstl to test the scenario you mentioned.

change
<h:graphicImage value="/images/Flag.gif" rendered="#{line.status.ID == 2}"/>

to

<c:if test="${line.status eq 'TEST STRING'}">
<h:graphicImage value="/images/Flag.gif" rendered="#{line.status.ID == 2}"/>
</c:if>

Before using <c:if> you should include the common taglib in your jsp using "<taglib>" tag.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
rendered="#{line.status.ID == 'TEST STRING'}"
 
Gabriel Claramunt
Ranch Hand
Posts: 375
Monad Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gregg Bolinger:
rendered="#{line.status.ID == 'TEST STRING'}"

Also you put the test string in a bundle and use

rendered="#{line.status.ID == myBundle.TEST_STRING}"
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!