1 Reply Latest reply on Jul 28, 2010 6:52 AM by Ilya Shaikovsky

    Splashscreen problem with extended data table

    Nail Ünlü Newbie

      Hello,

       

       

      Im in the process to integrate the extended data table to a existing view and having a hard time to make it work.

      I see the result of the rendering when i inspect with firebug but the table is now shown and a splashscreen with the loading animation appears..

       

      My Bean looks like

       

       

      package xxxxxx;


       


      import java.io.Serializable;
      import java.util.ArrayList;
      import java.util.Iterator;
      import java.util.List;


       


      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      import org.richfaces.model.DataProvider;
      import org.richfaces.model.ExtendedTableDataModel;
      import org.richfaces.model.selection.Selection;
      import org.richfaces.model.selection.SimpleSelection;


       


      import com.xxx.main.framework.JsfBean;
      import com.xxx.main.web.constants.BeanConstants;


       


      @Name(BeanConstants.RETAILLISTBEAN)
      @Scope(ScopeType.SESSION)
      public class RetailListBean implements JsfBean, Serializable {


       


          /**
           *
           */
          private static final long serialVersionUID = 6841091073165694873L;


       


               private List<RetailListItemBean> dataList; 
               private List<RetailListItemBean> selectedRetailListItem = new ArrayList<RetailListItemBean>();
               private Selection selection = new SimpleSelection();
               private ExtendedTableDataModel<RetailListItemBean> dataModel;
               private String sortMode="single";
              private String selectionMode="multi";
              private Object tableState;


       


              
              
               public void loadDataList() {      
                     
                   dataList = new ArrayList<RetailListItemBean>(); 
                    
                   RetailListItemBean sampleRow1 = new RetailListItemBean(); 
                   sampleRow1.setPos("1");
                   sampleRow1.setDescription("Sample Item 1");
                   sampleRow1.setArticleNumber("34234234");
            
            
                   RetailListItemBean sampleRow2 = new RetailListItemBean();
                   sampleRow2.setPos("2");
                   sampleRow2.setDescription("Sample Item 2");
                   sampleRow2.setArticleNumber("234234234");


       


                   RetailListItemBean sampleRow3 = new RetailListItemBean(); 
                   sampleRow3.setPos("3");
                   sampleRow3.setDescription("Sample Item 3");
                   sampleRow3.setArticleNumber("34234234");
            
            
                   RetailListItemBean sampleRow4 = new RetailListItemBean();
                   sampleRow4.setPos("4");
                   sampleRow4.setDescription("Sample Item 4");
                   sampleRow4.setArticleNumber("234234234");
                  
                  
                   RetailListItemBean sampleRow5 = new RetailListItemBean(); 
                   sampleRow5.setPos("5");
                   sampleRow5.setDescription("Sample Item 5");
                   sampleRow5.setArticleNumber("34234234");
            
            
                   RetailListItemBean sampleRow6 = new RetailListItemBean();
                   sampleRow6.setPos("6");
                   sampleRow6.setDescription("Sample Item 6");
                   sampleRow6.setArticleNumber("234234234");            
                  
                   dataList.add(sampleRow1);
                   dataList.add(sampleRow2);
                   dataList.add(sampleRow3);
                   dataList.add(sampleRow4);
                   dataList.add(sampleRow5);
                   dataList.add(sampleRow6);      
                  
                  
               } 
             
               public List <RetailListItemBean> getDataList() {         
                   loadDataList();  
                   return dataList; 
               } 
         
               public void takeSelection(){
                   selectedRetailListItem.clear();
                  Iterator<Object> iterator = getSelection().getKeys();
                  while (iterator.hasNext()) {
                      Object key = iterator.next();
                      selectedRetailListItem.add(getRetailListDataModel().getObjectByKey(key));
                  }
              }


       


              public ExtendedTableDataModel<RetailListItemBean> getRetailListDataModel() {


       



                      dataModel = new ExtendedTableDataModel<RetailListItemBean>(new DataProvider<RetailListItemBean>(){


       


                          private static final long serialVersionUID = 5054087821033164847L;


       


                          public RetailListItemBean getItemByKey(Object key) {
                              loadDataList();
                              for(RetailListItemBean c : dataList){
                                  if (key.equals(getKey(c))){
                                      return c;
                                  }
                              }
                              return null;
                          }


       


                          public List<RetailListItemBean> getItemsByRange(int firstRow, int endRow) {
                              return dataList.subList(firstRow, endRow);
                          }


       


                          public Object getKey(RetailListItemBean item) {
                              return item.getPos();
                          }


       


                          public int getRowCount() {
                              return dataList.size();
                          }
                         
                      });
                 
                  return dataModel;
              }
              
              
              public Selection getSelection() {
                  return selection;
              }


       


              public void setSelection(Selection selection) {
                  this.selection = selection;
              }


       


              public List<RetailListItemBean> getSelectedRetailListItem() {
                  return selectedRetailListItem;
              }


       


              public void setSelectedRetailListItem(List<RetailListItemBean> selectedRetailListItem) {
                  this.selectedRetailListItem = selectedRetailListItem;
              }
              public String getSortMode() {
                  return sortMode;
              }


       


              public void setSortMode(String sortMode) {
                  this.sortMode = sortMode;
              }


       


              public String getSelectionMode() {
                  return selectionMode;
              }


       


              public void setSelectionMode(String selectionMode) {
                  this.selectionMode = selectionMode;
              }


       


              public Object getTableState() {
                  return tableState;
              }


       


              public void setTableState(Object tableState) {
                  this.tableState = tableState;
              }


       


      }

       

       

       

       

      The XHTML looks like:

       

      {code:xml}

      <h:form id="form">
              <h:panelGrid columns="2" columnClasses="top , top">
                  <rich:extendedDataTable
                      value="#{retailListBean.retailListDataModel}" var="cap" id="table"
                      width="580px" height="400px"
                      sortMode="#{retailListBean.sortMode}"
                      selectionMode="#{retailListBean.selectionMode}"
                      tableState="#{retailListBean.tableState}"
                      selection="#{retailListBean.selection}">
                       <rich:column sortable="false" width="170px" label="">
                          <f:facet name="header">
                              <h:outputText value="" />
                          </f:facet>
                          <h:outputText value="" />
                      </rich:column>
                      <rich:column sortable="true" sortBy="#{dataItem.pos}" width="170px" label="Position">
                          <f:facet name="header">
                              <h:outputText value="pos" />
                          </f:facet>
                          <h:outputText value="#{dataItem.pos}" />
                      </rich:column>
                      <rich:column sortable="true" sortBy="#{dataItem.description}" label="Description">
                          <f:facet name="header">
                              <h:outputText value="Description" />
                          </f:facet>
                          <h:outputText value="#{dataItem.description}" />
                      </rich:column>
                      <rich:column sortable="true" label="Article Number" sortBy="#{dataItem.articleNumber}">
                          <f:facet name="header">
                              <h:outputText value="Article Number" />
                          </f:facet>
                          <h:outputText value="#{dataItem.articleNumber}" />
                      </rich:column>
                      <a4j:support reRender="selectiontable" id="extended_table_bean_take_selection"
                          action="#{retailListBean.takeSelection}"
                          event="onselectionchange" />
                  </rich:extendedDataTable>
                  <h:panelGroup layout="block" style="width:250px">
                      <rich:panel>
                          <f:facet name="header">
                              <h:outputText value="Sort/Selection modes changing" />
                          </f:facet>
                          <h:panelGrid columns="2">
                              <h:outputText value="Sort Mode:" />
                              <h:selectOneMenu value="#{retailListBean.sortMode}">
                                  <f:selectItem itemLabel="Single" itemValue="single" />
                                  <f:selectItem itemLabel="Multi" itemValue="multi" />
                                  <a4j:support event="onchange" ajaxSingle="true" reRender="table" id="support_sort_onchange"/>
                              </h:selectOneMenu>
                              <h:outputText value="Selection Mode:" />
                              <h:selectOneMenu value="#{retailListBean.selectionMode}">
                                  <a4j:support ajaxSingle="true" event="onchange" reRender="table" id="support_select_onchange"/>
                                  <f:selectItem itemLabel="Single" itemValue="single" />
                                  <f:selectItem itemLabel="Multi" itemValue="multi" />
                                  <f:selectItem itemLabel="None" itemValue="none" />
                              </h:selectOneMenu>
                          </h:panelGrid>
                      </rich:panel>
                      <rich:panel>
                          <f:facet name="header">
                              <h:outputText value="Currently selected rows:" />
                          </f:facet>
                          <rich:dataTable value="#{retailListBean.selectedRetailListItem}"
                              var="sel" id="selectiontable">
                              <rich:column>
                                 <h:outputText value="" />
                              </rich:column>
                              <rich:column>
                                  <h:outputText value="#{sel.pos}" />
                              </rich:column>
                              <rich:column>
                                  <h:outputText value="#{sel.description}" />
                              </rich:column>
                              <rich:column>
                                  <h:outputText value="#{sel.articleNumber}" />
                              </rich:column>
                          </rich:dataTable>
                      </rich:panel>
                  </h:panelGroup>
              </h:panelGrid>
          </h:form>

      {code}

       

       

      does anyone have an idea?