3 Replies Latest reply on Nov 13, 2008 9:17 AM by fezen

    a4j:repeat

      hey everyone,
      i've been trying to use the repeat component to get the index of the clicked row, but i keep getting -1 when i call getRowIndex() on the UIRepeat object. this happens indendently of which row i click. the row count obtained via the getRowCount() method is correct and also when i print the row numbers on the website they seem correct.

      here is the xhtml code:

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE html
       PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
      
      <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:a4j="http://richfaces.org/a4j"
       xmlns:rich="http://richfaces.org/rich">
      
      <body>
      
      <ui:composition>
      
       <h:form>
       <a4j:keepAlive beanName="finanzflussBean" />
      
       <a4j:repeat value="#{finanzflussBean.finanzfluesse}" var="item"
       binding="#{finanzflussBean.repeater}">
       <a4j:outputPanel styleClass="af_box">
       <h:outputText value="TEST" />
       <a4j:support event="onclick"
       action="#{finanzflussBean.expandFinanzfluss}" />
       </a4j:outputPanel>
       </a4j:repeat>
      
       </h:form>
      
      </ui:composition>
      
      </body>
      </html>


      and here the code fragment from the BackingBean:

      public String expandFinanzfluss() {
       int rowKey = this.getRepeater().getRowIndex();
      
      
       return null;
       }
      


        • 1. Re: a4j:repeat
          ilya_shaikovsky

          I think you should avoid keepAlive in this case for the bean which contains binding. Seems previous value restored later than actual value applied.
          We'll check this in order to get correct explanation.. but I could advice you to split the data bean and binding bean and store only the data bean with keapAlive.

          • 2. Re: a4j:repeat
            nbelaevski

            what

            #{finanzflussBean.finanzfluesse}
            is?

            • 3. Re: a4j:repeat
              fezen

              Bumping this...

              I also get -1 from getRowIndex() when I use <a4j:keepalive>. Is there any way to get getRowIndex() to return the correct row while using keepalive? I guess an attribute and a rowKeyVar will do the trick to, but it would be nice to use getRowIndex() instead.