public Iterator<T> iterator(int first, int count) { List<T> items = getFilteredItems(); // global sorting Comparator<T> comparator = getComparator(getSort()); if (comparator != null) { Collections.sort(items, comparator); } // in memory paging int last = first + count; if (last > items.size()) last = items.size(); return items.subList(first, last).iterator(); }
/** @see org.apache.wicket.markup.repeater.data.IDataProvider#iterator(int, int) */ @Override public Iterator<T> iterator(long first, long count) { List<T> items = getFilteredItems(); // global sorting Comparator<T> comparator = getComparator(getSort()); if (comparator != null) { Collections.sort(items, comparator); } if (items.size() <= count) { // the list has been paged for us. return items.iterator(); } // in memory paging long last = first + count; if (last > items.size()) last = items.size(); return items.subList((int) first, (int) last).iterator(); }
@Override public void onClick(AjaxRequestTarget target) { SortParam currSort = dataProvider.getSort(); Property<T> property = (Property<T>) getModelObject(); if (currSort == null || !property.getName().equals(currSort.getProperty())) { dataProvider.setSort(new SortParam(property.getName(), true)); } else { dataProvider .setSort(new SortParam(property.getName(), !currSort.isAscending())); } setSelection(false); target.addComponent(listContainer); }
@Override public void onClick(AjaxRequestTarget target) { SortParam<?> currSort = dataProvider.getSort(); @SuppressWarnings("unchecked") Property<T> property = (Property<T>) getModelObject(); if (currSort == null || !property.getName().equals(currSort.getProperty())) { dataProvider.setSort(new SortParam<Object>(property.getName(), true)); } else { dataProvider.setSort( new SortParam<Object>(property.getName(), !currSort.isAscending())); } setSelection(false); target.add(listContainer); } };