3 Replies Latest reply on Jun 17, 2009 10:33 AM by Israel Fonseca

    ReRendering Rows (Ajax Keys?)

    Israel Fonseca Apprentice

      I want to rerender the a row in a dataTable. The row that i want to reRender is the same one that have the button that triggers this reRender. I tried lot of different ways to do this, and it did not work, even using the ajaxKeys atribute (but i didnt understand it very well so it could be my fault). Anyway that's the code:

       <a4j:form id="lista">
       <rich:spacer height="10" />
       <rich:datascroller for="dataTable" maxPages="20" binding="#{consultarComprovante.datascroller}" scrollerListener="#{consultarComprovante.scrollerListener}" id="scrollCategoria" />
       <rich:dataTable id="dataTable" rendered="#{not empty consultarComprovante.lista}"
       value="#{consultarComprovante.lista}" var="item" rows="#{consultarComprovante.rows}" rowKeyVar="row"
       headerClass="data_table_header" border="0" styleClass="tabela_dados">
      
       <rich:column>
       <a4j:commandButton value="#{tree.isOpen(row) ? '-' : '+'}" action="#{tree.change(row)}" ajaxSingle="true" reRender="lista" style="width:30px"/>
       </rich:column>
       <rich:column id="primeiraColuna">
       <f:facet name="header">
       Data
       </f:facet>
       <h:outputText value="#{item.data}" />
       </rich:column>
       <rich:column>
       <f:facet name="header">
       Quantidade
       </f:facet>
       <h:outputText value="#{item.quantidade}" />
       </rich:column>
       <rich:column>
       <f:facet name="header">
       Valor Total
       </f:facet>
       <h:outputText value="#{item.valorTotal}">
       <f:convertNumber type="currency" currencySymbol="R$" groupingUsed="true" />
       </h:outputText>
       </rich:column>
      
       <rich:subTable rendered="#{tree.isOpen(row)}" var="subitem" value="#{comprovanteBO.listarComprovantesPorData(item.data)}">
       <rich:column>
       <f:facet name="header">
       Valor
       </f:facet>
       <h:outputText value="#{subitem.valor}">
       <f:convertNumber type="currency" currencySymbol="R$" groupingUsed="true" />
       </h:outputText>
       </rich:column>
       <rich:column colspan="2">
       <f:facet name="header">
       Número Ponto de Venda
       </f:facet>
       <h:outputText value="#{subitem.lote.numeroPontoVenda}" />
       </rich:column>
       <rich:column>
       <f:facet name="header">
       Quantidade
       </f:facet>
       <h:outputText value="#{subitem.lote.descricaoEstabelecimento}" />
       </rich:column>
       </rich:subTable>
      
       </rich:dataTable>
       </a4j:form>
      


      I just want that the a4j:commandButton reRenders the subTable to show other registers about that register. I tried to surround the subTable with an a4j:outputPanel and reRender it, but it didn't work. The visual effect that i want to achieve is a dataTable row that can be "opened". How can i achieve this? The only way for now is reRendering all the table, but it's definitely a bad thing to do.

        • 1. Re: ReRendering Rows (Ajax Keys?)
          Roland Schöler Newbie

          Hi israel.bgf, maybe this link will give you some hints for your problem how to use AjaxKeys - I believe they would be the correct solution for your problem

          http://java.dzone.com/articles/an-introduction-to-jboss-richf?page=1,5

          regards
          rschoeler

          • 2. Re: ReRendering Rows (Ajax Keys?)
            Israel Fonseca Apprentice

             

            "rschoeler" wrote:
            Hi israel.bgf, maybe this link will give you some hints for your problem how to use AjaxKeys - I believe they would be the correct solution for your problem

            http://java.dzone.com/articles/an-introduction-to-jboss-richf?page=1,5

            regards
            rschoeler


            Thks for the fast reply rschoeler. This link was useful indeed. So we use ajaxKeys when outside the dataTable we want to reRender some row right? But inside de dataTable to reRender something of the current row we dont need it, the reRender does it "automagically". Anyway, i used the ajaxKeys and got the same problem. But I did something to illustrate better the problem, and now it's really strange. Look:

            
             <a4j:form id="lista">
             <rich:spacer height="10" />
             <rich:datascroller for="dataTable" maxPages="20" binding="#{consultarComprovante.datascroller}" scrollerListener="#{consultarComprovante.scrollerListener}" id="scrollCategoria" />
             <rich:dataTable id="dataTable" rendered="#{not empty consultarComprovante.lista}"
             value="#{consultarComprovante.lista}" var="item" rows="#{consultarComprovante.rows}" rowKeyVar="row" ajaxKeys="#{consultarComprovante.ajaxKeys}"
             headerClass="data_table_header" border="0" styleClass="tabela_dados">
            
             <rich:column id="controller">
             <a4j:commandButton value="#{tree.isOpen(row) ? '-' : '+'}" action="#{consultarComprovante.change(row)}" ajaxSingle="true" reRender="controller, subTable" style="width:30px"/>
             </rich:column>
             <rich:column>
             <f:facet name="header">
             Data
             </f:facet>
             <h:outputText value="#{item.data}" />
             </rich:column>
             <rich:column>
             <f:facet name="header">
             Quantidade
             </f:facet>
             <h:outputText value="#{item.quantidade}" />
             </rich:column>
             <rich:column>
             <f:facet name="header">
             Valor Total
             </f:facet>
             <h:outputText value="#{item.valorTotal}">
             <f:convertNumber type="currency" currencySymbol="R$" groupingUsed="true" />
             </h:outputText>
             </rich:column>
            
             <rich:column id="subTable" colspan="4" breakBefore="true">
             #{random}
             <br/>
             #{tree.isOpen(row) ? 'true' : 'false'}
             <rich:subTable rendered="#{tree.isOpen(row)}" var="subitem" value="#{comprovanteBO.listarComprovantesPorData(item.data)}">
             <rich:column>
             <f:facet name="header">
             Valor
             </f:facet>
             <h:outputText value="#{subitem.valor}">
             <f:convertNumber type="currency" currencySymbol="R$" groupingUsed="true" />
             </h:outputText>
             </rich:column>
             <rich:column colspan="2">
             <f:facet name="header">
             Número Ponto de Venda
             </f:facet>
             <h:outputText value="#{subitem.lote.numeroPontoVenda}" />
             </rich:column>
             <rich:column>
             <f:facet name="header">
             Quantidade
             </f:facet>
             <h:outputText value="#{subitem.lote.descricaoEstabelecimento}" />
             </rich:column>
             </rich:subTable>
             </rich:column>
            
             </rich:dataTable>
             </a4j:form>
            
            


            (First of all I'm using Seam 2.1.1 with RichFaces 3.3.1)

            As you can see i put this "#{random}" in the subTable that i want to reRender, with this i can see if the reRender is working (it returns a random number in the view). And it working is indeed. When i click in the button i see the number changing, so that's mean that the reRender is working in the right place, but my subTable do not get rendered.

            So you could thing that my rendered="#{tree.isOpen(row)}" is not working, well.. the problem is, if I do a full page refresh (F5) after clicking the button, it works! And as you can see, i put the
            #{tree.isOpen(row) ? 'true' : 'false'} at the side of the "#{random} to prove that it's working (after clicking i see it becoming true too).

            So that's all very strange to me. :)

            Is it a bug with the subTable? Or am I still doing something wrong?

            Thks in advance,

            Israel

            • 3. Re: ReRendering Rows (Ajax Keys?)
              Israel Fonseca Apprentice

              STRANGE, well the problem was the rendered attribute of the subTable indeed. I put a a4j:outputPanel and, put the rendered clause there, and now it's working, the layout of the table crashed a little but i can survive with this.

              But so, is it a bug? Should it be posted on JIRA?