String contains method in jsf
Asked Answered
R

2

13

i was wondering how to use/implement string contains method in jsf2 without using JSTL. please advise, thanks.

Radioelement answered 3/12, 2012 at 10:58 Comment(0)
G
28
<h:outputText value="#{'I love JSF'.contains('JSF')}" /> <!-- true -->

OR

<h:outputText value="#{myBean.text.contains('some_word')}" />
Galibi answered 3/12, 2012 at 11:14 Comment(1)
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())}Galibi
T
10

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')}"
Tasman answered 3/12, 2012 at 11:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.