i was wondering how to use/implement string contains method in jsf2 without using JSTL. please advise, thanks.
Asked
Active
Viewed 2.2k times
2 Answers
24
<h:outputText value="#{'I love JSF'.contains('JSF')}" /> <!-- true -->
OR
<h:outputText value="#{myBean.text.contains('some_word')}" />
![](../../users/profiles/1023421.webp)
prageeth
- 6,524
- 7
- 38
- 66
-
There is no such method. However you can similarly use other java `String` methods. So you can implement case insensitive `contains` feature like this. `#{'i love JSF'.toLowerCase().contains('JSF'.toLowerCase())}` – prageeth Dec 03 '12 at 11:32
5
In addition you can use JSTL functions
Add this:
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
And use it like this
render="#{fn:contains(myBean.myText, 'test')}"
![](../../users/profiles/617373.webp)
Daniel
- 35,598
- 9
- 108
- 184