10 Replies Latest reply on Mar 7, 2010 1:57 AM by Eugene Bessel

    partially loading of data

    Eugene Bessel Newbie

      hello everybody,

       

      I made a performance test of extendedDataTable. I generated the ArrayList for table with 50000 rows. the table has a table scroller like in

      http://livedemo.exadel.com/richfaces-demo/richfaces/dataTableScroller.jsf;jsessionid=B1D416A06340C4A7B365977EC9010403?c=dataTableScroller&tab=usage

       

       

      there are 20 rows in page.

       

      the sorting and filtering of the datatable is very slow.

       

      my question is, is there the posibility to show the first page while the whole table is generated??????

       

      thank you for the answer.

        • 1. Re: partially loading of data
          Eugene Bessel Newbie
          perhaps  is DataScroller the correct component for it???
          • 2. Re: partially loading of data
            Ilya Shaikovsky Master
            you could improve the performance by implementing "true paggination" like there http://livedemo.exadel.com/richfaces-demo/richfaces/dataTable.jsf?tab=dataModel and there http://livedemo.exadel.com/richfaces-demo/richfaces/dataTable.jsf?tab=modifiableDataModel in order to deal only with curernt page data.
            • 3. Re: partially loading of data
              Eugene Bessel Newbie

              sorry, but I didnt understand you. which method is responsible for pagination???

               

              I can not see any pagi* in Tag-information

              • 4. Re: partially loading of data
                Ilya Shaikovsky Master
                data model responsible for that. checkout full dem sources from svn to look through.
                • 5. Re: partially loading of data
                  Eugene Bessel Newbie

                  hello Ilja,

                   

                  I looked into the examples AuctionDataModel.

                  http://livedemo.exadel.com/richfaces-demo/richfaces/dataTable.jsf?tab=dataModel&cid=6128375

                   

                  I have some questions about it.

                   

                  In this example we know which objects exist.

                  I work with attribute columns and use List<ArrayList<String>> as DataModel. Just a list of Strings, which shoud be shown in dataTable.

                   

                  please correct me if I stay wrong:

                  public class AuctionDataModel extends SerializableDataModel {

                   

                      private AuctionDataProvider dataProvider;
                      private Integer currentPk;    // DO WE NEED currentPk for this case???? what is Pk for the List<ArrayList<String>> ???
                      private Map<Integer,ArrayList<Strng>> wrappedData = new HashMap<Integer,ArrayList<String>>();
                      private List<Integer> wrappedKeys = null;

                   

                      public void walk(FacesContext context, DataVisitor visitor, Range range, Object argument) throws IOException {
                          int firstRow = ((SequenceRange)range).getFirstRow();
                          int numberOfRows = ((SequenceRange)range).getRows();
                          wrappedKeys = new ArrayList<Integer>();
                          for (ArrayList<String> item:getDataProvider().getItemsByrange(new Integer(firstRow), numberOfRows)) {
                              wrappedKeys.add(item.getPk());        // I dont have Pk on this place
                              wrappedData.put(item.getPk(), item);
                              visitor.process(context, item.getPk(), argument);
                          }
                      }

                   

                  I dont know how should I implement this model for extendedDataTable with <rich:columns

                  can you please help me.

                   

                  thank you

                  • 6. Re: partially loading of data
                    Eugene Bessel Newbie

                    I tried to implement PK=item.get(0).

                     

                    I have modified the example auctionDataModel

                     

                    Now I have some troubles:

                    the line:

                           dataProvider = lookupInContext(auctionDataProviderExpressionString, AuctionDataProvider.class);

                    provides null.

                     

                    If I initialize dataProvide directly like

                          private AuctionDataProvider dataProvider = new AuctionDataProvider();

                    then I have an object and the table is displayd, BUT without data.

                    The cause is:

                    the method getRowData()  provides null

                     

                    the cause is: currentPK is not setted.

                     

                    on this place the question. who should set the value for currentPK???????

                     

                    I setted brakepoint into setter and it go in, but the value for currentPK is always null.

                     

                    any idea?

                     

                    thank you

                    • 7. Re: partially loading of data
                      gamba Newbie

                      Hi Eugene,

                       

                      I'm facing the same situation. I found another example in the source (via SVN) in

                       

                      richfaces-ui-3.3.2.SR1\samples\richfaces-demo\src\main\java\org\richfaces\demo\extendedDataTable

                       

                      Maybe this could help you. The interesting snippet is this one:

                       

                          ...
                          public ExtendedTableDataModel<Capital> getCapitalsDataModel() {
                              if (dataModel == null) {
                                  dataModel = new ExtendedTableDataModel<Capital>(new DataProvider<Capital>(){
                      
                                      private static final long serialVersionUID = 5054087821033164847L;
                      
                                      public Capital getItemByKey(Object key) {
                                          for(Capital c : capitals){
                                              if (key.equals(getKey(c))){
                                                  return c;
                                              }
                                          }
                                          return null;
                                      }
                      
                                      public List<Capital> getItemsByRange(int firstRow, int endRow) {
                                          return capitals.subList(firstRow, endRow);
                                      }
                      
                                      public Object getKey(Capital item) {
                                          return item.getName();
                                      }
                      
                                      public int getRowCount() {
                                          return capitals.size();
                                      }
                                      
                                  });
                              }
                              return dataModel;
                          }
                      

                       

                       

                      You can change the "Capital"-object with your own.

                       

                      Greets

                      Holger

                      • 8. Re: partially loading of data
                        Eugene Bessel Newbie

                        Hello Holger,

                         

                        thank you for your advice. I also tried to implement your example, but the table is still empty. I think I must initialize the data of the table. In your example I can not see any init method.

                         

                        where come the dataValues from??

                        • 9. Re: partially loading of data
                          Eugene Bessel Newbie

                          my Model looks like:

                           

                          public ExtendedTableDataModel<ArrayList<String>> getCapitalsDataModel() {
                                  if (extendedDataModel == null) {
                                      extendedDataModel = new ExtendedTableDataModel<ArrayList<String>>(new DataProvider<ArrayList<String>>(){

                                          private static final long serialVersionUID = 5054087821033164847L;

                                          public ArrayList<String> getItemByKey(Object key) {
                                              for(ArrayList<String> c : dataList){
                                                  if (key.equals(getKey(c))){
                                                      return c;
                                                  }
                                              }
                                              return null;
                                          }

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

                                          public Object getKey(ArrayList<String> item) {
                                              return item.get(0);
                                          }

                                          public int getRowCount() {
                                              return dataList.size();
                                          }
                                         
                                      });
                                  }
                                  return extendedDataModel;
                              }

                           

                          is it correct??

                          • 10. Re: partially loading of data
                            Eugene Bessel Newbie

                            has anybody an idea how should I implement DataModel for the dynamic DataTable with attribute columns??