I want create an array in JSF EL. How can I do that? Is it even possible?
To illustrate what I am trying:
<rich:pickList addAllText="" addText="" removeAllText="" removeText="">
<f:selectItems value="#{'Test', 'TestTest', 'TestTestTest'}" />
</rich:pickList>
If you're on EL 3.0 or newer, you can construct collections directly in EL.
<f:selectItems value="#{['Test','TestTest','TestTestTest']}" />
If you're not on EL 3.0 yet, you could solve this particular case with a fn:split()
trick.
<html ... xmlns:fn="http://java.sun.com/jsp/jstl/functions">
...
<f:selectItems value="#{fn:split('Test,TestTest,TestTestTest', ',')}" />
Either way, this requires a minimum of JSF 2.0 for the support of List<T>
in <f:selectItems>
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With