How to create an array in JSF EL?

el, jsf, jsp

Solution

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>`.

Problem

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> ```

Original source