Obtain length of string in EL
16,671
If you just need to know if it's empty or null, use EL empty
keyword:
<ui:fragment rendered="#{not empty bean.string}">
Or if you really need to know its exact length, use String#length()
method directly:
<ui:fragment rendered="#{bean.string.length() gt 42}">
Or if you aren't on Servlet 3.0 / EL 2.2 yet, use JSTL fn:length()
function:
<ui:fragment rendered="#{fn:length(bean.string) gt 42}">
Author by
user679526
Updated on July 30, 2022Comments
-
user679526 almost 2 years
Can we find the length of a
String
in Facelets page to check for a condition using<ui:fragment>
? -
user679526 over 12 yearsThank you BalusC. I replaced size to length. The whole time I was considering it to be a list instead of string.