7 Replies Latest reply on Jan 21, 2010 12:58 PM by nbelaevski

    rich:dataTable accessing data from backing bean

    zelenka

      Hi,

       

      on page I use rich:datatable and some columns use filterBy feature. In backing bean I would like to sum one column when user changes value. Problem is that my code only walks through displayed (filtered) rows. How to access all rows?

       

      Thanks

       

      <h:outputText id="sumks" value="#{MyBean.sumData}"/></td>

      <rich:dataTable ..... binding="#{MyBean.htmlDataTable}" id="table">

           ...

           <rich:column>
                <h:inputText value="..." id="ks">
                     <a4j:support event="onchange" reRender="sumks"/>
                </h:inputText>
           </rich:column>

       

      public Integer getSumData() {
              Integer sum= 0;
              for (int i = 0; i < htmlDataTable.getRowCount(); i++) {
                  htmlDataTable.setRowIndex(i);
                  UIComponent ks = htmlDataTable.findComponent("ks");
                  sum= sum+ (Integer) ((HtmlInputText) ks).getValue();
              }
              return sum;
          }