2 Replies Latest reply on Aug 18, 2008 3:36 AM by Daniel Soneira

    rowindex in a4j:repeat

    Gergely Nagy Newbie


      We need to access the row index (iteration variable) when using a4j:repeat.

      I noticed that a4j:repeat exposes the stateVar, which currently only exposes the SequenceRange. I patched this as follows:

      public abstract class SequenceDataAdaptor extends UIDataAdaptor {

      protected DataComponentState createComponentState() {
      return new DataComponentState(){
      public Range getRange() {
      return new SequenceRange(getFirst(),getRows());
      // added this new method
      public int getRowIndex() {
      return SequenceDataAdaptor.this.getRowIndex();

      However, i cannot get at the row index value.

      Take one: try to print the range -- it works

      <a4j:repeat value="#{items}" var="item" stateVar="state">
      <h:outputText value="#{state.range}"/>
      output: org.ajax4jsf.model.SequenceRange@fb8c90

      Take two: try to print an invalid property -- it is correctly not found on the anonymous inner class

      <a4j:repeat value="#{items}" var="item" stateVar="state">
      <h:outputText value="#{state.foo}"/>
      output: javax.el.PropertyNotFoundException: /ajaxtest.xhtml @19,39 value="#{state.foo}": Property 'foo' not found on type org.ajax4jsf.component.SequenceDataAdaptor$1

      Take three: try to print the row index. it seems to be resolved on the integer type, and not the anonymous inner class??

      <a4j:repeat value="#{items}" var="item" stateVar="state">
      <h:outputText value="#{state.rowIndex}"/>
      output: javax.el.PropertyNotFoundException: /ajaxtest.xhtml @19,44 value="#{state.rowIndex}": Property 'rowIndex' not readable on type int

      I wonder what's going on. Any ideas? Or any other solution to get at the currently iterated row index?