Results 1 to 2 of 2

Thread: PagingLoader with pageSize=0

  1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    14

    Default PagingLoader with pageSize=0

    I've extended PagingLoader and have overriden load(PagingLoadConfig config) method. And used as loader in ComboBox.

    As investigated the ComboBoxCell changes load config to incompatible instance depends on pageSize value itself:

    Code:
      protected ListLoadConfig getParams(String query) {    if (pageSize > 0) {
          PagingLoadConfig config = null;
          if (loader.isReuseLoadConfig()) {
            config = (PagingLoadConfig) loader.getLastLoadConfig();
          } else {
            config = new PagingLoadConfigBean();
          }
          config.setLimit(pageSize);
          config.setOffset(0);
          return config;
        } else {
          ListLoadConfig config = null;
          if (loader.isReuseLoadConfig()) {
            config = (ListLoadConfig) loader.getLastLoadConfig();
          } else {
            config = new ListLoadConfigBean();
          }
          return config;
        }
      }
    calling snippet in doQuery(..) :

    Code:
              @SuppressWarnings("unchecked")          ListLoader<ListLoadConfig, ListLoadResult<?>> l = (ListLoader<ListLoadConfig, ListLoadResult<?>>) loader;
    
    
              // delay expanding - hide the empty list with shadow until something is loaded.
              if (listView.getLoadingHtml() == null) {
                final GroupingHandlerRegistration tmpHandler = new GroupingHandlerRegistration();
                LoadHandler<ListLoadConfig, ListLoadResult<?>> loadHandler = new LoadHandler<ListLoadConfig, ListLoadResult<?>>() {
                  @Override
                  public void onLoad(LoadEvent<ListLoadConfig, ListLoadResult<?>> event) {
                    tmpHandler.removeHandler();
                    expand(context, parent, updater, value);
                  }
                };
                tmpHandler.add(l.addLoadHandler(loadHandler));
              }
    
    
              l.load(getParams(query));


    I've messed up with this code approach. Some questions to developers:

    How to get around of threw ClassCastException (ListLoadConfigBean tries to cast as PagingLoadConfig) on l.load(getParams(query))?
    Why not use "instanceof" when detecting config version in above code?
    What if i try to extend ListLoadConfig and use in my own loader? I guess ComboBoxCell cannot handle it ever. Right?

  2. #2
    Sencha User
    Join Date
    Jun 2011
    Posts
    14

    Default

    The current workaround is using following class and creating comboboxes using this one.

    Code:
    public class BaseComboBoxCell<T> extends ComboBoxCell<T> {
    
        public BaseComboBoxCell(ListStore<T> store, LabelProvider<? super T> labelProvider, final SafeHtmlRenderer<T> renderer) {
            super(store, labelProvider, renderer);
        }
    
    
        @Override
        protected ListLoadConfig getParams(String query) {
            // todo CustomLoader?
            if (loader instanceof PageLoader) {
                PagingLoadConfig config = null;
                if (loader.isReuseLoadConfig()) {
                    config = (PagingLoadConfig) loader.getLastLoadConfig();
                } else {
                    config = new PagingLoadConfigBean(0, pageSize);
                }
                return config;
            } else {
    //ListLoader assumed
                ListLoadConfig config = null;
                if (loader.isReuseLoadConfig()) {
                    config = (ListLoadConfig) loader.getLastLoadConfig();
                } else {
                    config = new ListLoadConfigBean();
                }
                return config;
            }
        }
    }

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •