2 Replies Latest reply on Jul 29, 2011 12:47 AM by himanshu.bhardwaj

    value attribute is getting called twice when using extendedDataTable

    himanshu.bhardwaj

      Hi All,

       

      Am trying to implement extendedDataTable but facing the issue that the value attribute is getting invoked twice, because of which the table data is getting duplicated. I am not able to figure whether I am doing it wrong or am I mssing anything.

       

      Thanks

       

      <code>

      This is my javacode which is invoked:

       

      public List<TestBean> getListBean() {

              TestBean t1 = new TestBean();

              t1.setId(1);

              t1.setAge(10);

              t1.setName("XXX");

              TestBean t2 = new TestBean();

              t2.setId(2);

              t2.setAge(14);

              t2.setName("YYY");

              TestBean t3 = new TestBean();

              t3.setId(3);

              t3.setAge(15);

              t3.setName("ZZZ");

              listBean.add(t1);

              listBean.add(t2);

              listBean.add(t3);

              return listBean;

          }

       

          /**

           * @return the listAllBean

           */

          public List<TestBean> getListAllBean() {

              System.out.println("Query here will call the database code");

              return getListBean();

          }

       

      This is my jsp:

      <!doctype html public "-//w3c//dtd html 4.0 transitional//en">

       

      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

       

      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>

       

      <!-- RichFaces tag library declaration -->

       

      <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>

       

      <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>

       

      <ui:composition xmlns="http://www.w3.org/1999/xhtml"

       

                      xmlns:ui="http://java.sun.com/jsf/facelets"

       

                      xmlns:a4j="http://richfaces.org/a4j"

       

                      xmlns:rich="http://richfaces.org/rich">

      </ui:composition>

       

      <html>

          <f:view>

              <h:form>

                  <%--<rich:datascroller for="testList" maxPages="100"/>--%>

                  <rich:spacer height="20" />

                  <rich:extendedDataTable id="testList" value="#{testGroupBean.listAllBean}" var="item">

                      <rich:column>

                          <f:facet name="header">

                              <h:outputText value="age" />

                          </f:facet>

                          <h:outputText value="#{item.age}" />

                      </rich:column>

                      <rich:column>

                          <f:facet name="header">

                              <h:outputText value="Name" />

                          </f:facet>

                          <h:outputText value="#{item.name}" />

                      </rich:column>

                  </rich:extendedDataTable>

              </h:form>

          </f:view>

       

      </html>

      </code>

        • 1. Re: value attribute is getting called twice when using extendedDataTable
          himanshu.bhardwaj

          Hi All,

           

          I got the problem. The problem is basically the approach am following. Am retreiving the list in the getter method. But if I go through the life cycle of a JSF. Then in all there are 6 phases and as per the requirements the different phases access the getters and setters. So each time I do some processing mutiple time getters and setters are called causing the data to be duplicated.

           

          This solves the issue of duplicacy, but I still need to find a way to populate the data.

           

          If anyone has any idea let know.

           

          Will keep posted on the new findings.

           

          Thanks

          • 2. Re: value attribute is getting called twice when using extendedDataTable
            himanshu.bhardwaj

            I managed it, by implementing a custom pagination control and using constructors for initializations of list. Moreover I managed the refreshing of list data by implementing listeners and using a4j:support. Works perfectly fine now. The only problem I see is that even if the list data is dynamically loaded still I have to make  the scope session for it, I am still trying to understand the reason for this.