Below is a snippet of code in which an apex:variable is not increment inside an apex:repeat tag. In this case, the var="rowCount" gets incremented without any issues, but the var="headerCount" does not increment at all. Can anyone provide some insight?
Sample Code
<apex:pageBlock >
<!-- Tracks the row in the table -->
<apex:variable var="rowCount" value="{!-1}" />// This variable increments properly
<apex:variable var="headerCount" value="{!0}" />// This variable does not increment at all
<apex:pageBlockSection columns="1" title="{!Title}" id="pbSec">
<apex:pageBlockTable value="{!sObjRecords}" var="sObj" styleClass="dataTable table table-fixedheader" id="pageBlockTable">
<!-- Displays the multiple columns based on the user input -->
<apex:repeat value="{!Fields}" var="fld">
<apex:column >
<apex:outputText value="{!sObj[fld]}"/>
<apex:facet name="header">{!headers[headerCount]}</apex:facet>
<apex:variable var="headerCount" value="{!headerCount+1}" />
</apex:column>
</apex:repeat>
<!-- Action Column with buttons - May not be used if attribute is false -->
<apex:column rendered="{!IsActionColumnEnabled}" >
<apex:facet name="header">{!$Label.YAHS_PRT_Action}</apex:facet>
<apex:repeat value="{!Buttons}" var="button">
<apex:variable var="rowCount" value="{!rowCount+1}" />
</apex:repeat>
).!Fields
to!headers
. This would normally be done via a wrapper class.