Search code examples
jsfrichfacesjstljsf-1.2

I have a c:set variable in Java. I want to +1 to the value in a rich:dataTable, is this possible?


I have a c:set variable in Java. I want to +1 to the value in a rich:dataTable, is this possible?

    <h:form id="webstoreSettings" styleClass="edit">
        <c:set var="_count" value="0" scope="page" />
        <rich:panel>
            <rich:simpleTogglePanel label="Store Properties"
                switchType="client" rendered="true">
                <div style="margin: 7px 0px;">
                    <rich:dataTable id="webListsTable"
                        value="#{storeHome.webPropertiesVars}" var="_var">
                        <h:column id="webstoreVarCol">
                            <h:outputLabel id="webstoreVar_#{_count}" value="#{_var.webstoreVar}" />
                            <c:set var="_count" value="#{_count + 1}" scope="page" />
                        </h:column>
                    </rich:dataTable>
                </div>
            </rich:simpleTogglePanel>
        </rich:panel>
    </h:form>

All of the id="webstoreVar_0" are the same :(

Thanks.


Solution

  • This is not possible. JSTL tags run during view build time, not during view render time. The <rich:dataTable var> is only available during view render time.

    I'm not sure why exactly you need a <h:outputLabel id> like that. It makes no sense. Just remove the EL from the id attribute. JSF will already prepend it with the row index of the data table.

    <h:outputLabel id="webstoreVar" ... />
    

    See also: