Can we find the length of a String
in Facelets page to check for a condition using <ui:fragment>
?
Obtain length of string in EL
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}">
Thank you BalusC. I replaced size to length. The whole time I was considering it to be a list instead of string. –
Weeper
© 2022 - 2024 — McMap. All rights reserved.