varstatus attribute in ui:repeat in jsf 1.2

Archer picture Archer · May 1, 2012 · Viewed 7.3k times · Source

How do I implement the functionality of varstatus attribute in ui:repeat in JSF 1.2? If it can't be used in version 1.2, what are the available options to get the first and last item of an arraylist?

Kindly help me by providing your ideas.

Answer

BalusC picture BalusC · May 2, 2012

Use JSTL's <c:forEach> instead.

<c:forEach items="#{bean.items}" var="item" varStatus="loop">
    <c:if test="#{loop.first}">First</c:if>
    <h:outputText value="#{item}" />
    <c:if test="#{loop.last}">Last</c:if>
</c:forEach>

Or use Tomahawk's <t:dataList> instead.

<t:dataList value="#{bean.items}" var="item" rowCountVar="count" rowIndexVar="index">
    <h:outputText value="First" rendered="#{index == 0}" />
    <h:outputText value="#{item}" />
    <h:outputText value="Last" rendered="#{index + 1 == count}" />
</t:dataList>