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

    rich:dataTable accessing data from backing bean

    Pavel Zelenka Newbie



      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?




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

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


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


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