- 

Available since OmniFaces 1.0

Collection of EL functions for array manipulation: of:createArray(), of:createIntegerArray(), of:contains() and of:reverseArray().

Feature request

If you know more useful methods/functions which you think should be added to this OmniFaces utility class so that everyone can benefit from a "standard" Faces utility library, feel free to post a feature request.

Demo

Create a dummy array of size 5: 0, 1, 2, 3, 4

Create an integer array from 10 to 20: 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20

Create an integer array for <f:selectItems>: chosen: 1 and 2003

Check if an array contains the specified value: clicking here should print true: false

Demo source code
<p>
    Create a dummy array of size 5:
    <ui:repeat value="#{of:createArray(5)}" varStatus="loop">
        #{loop.index}#{!loop.last ? ', ' : ''}
    </ui:repeat>
</p>

<p>
    Create an integer array from 10 to 20:
    <ui:repeat value="#{of:createIntegerArray(10, 20)}" var="i" varStatus="loop">
        #{i}#{!loop.last ? ', ' : ''}
    </ui:repeat>
</p>

<h:form>
    <p>
        Create an integer array for <code>&lt;f:selectItems&gt;</code>:
        <h:selectOneMenu value="#{functionsBean.day}">
            <f:selectItems value="#{of:createIntegerArray(1, 31)}" />
            <f:ajax render="day" />
        </h:selectOneMenu>

        <c:set var="year" value="#{of:formatDate(now, 'yyyy')}" />
        <h:selectOneMenu value="#{functionsBean.year}">
            <f:selectItems value="#{of:createIntegerArray(year, year - 10)}" />
            <f:ajax render="year" />
        </h:selectOneMenu>

        chosen: <strong><h:outputText id="day" value="#{functionsBean.day}" /></strong>
        and <strong><h:outputText id="year" value="#{functionsBean.year}" /></strong>
    </p>
</h:form>

<p>
    Check if an array contains the specified value: 
    <a href="?test=7&amp;test=42&amp;test=69">clicking here should print true</a>:
    <strong>#{of:contains(paramValues.test, 42)}</strong>
</p>