DataTable lazyload issue in RC2

UI Components for JSF
Post Reply
substanceoflife
Posts: 9
Joined: 15 Nov 2010, 11:25

25 Nov 2010, 16:49

Hi guys,

Did anybody face with such issue that when you use lazy loading in datatable the data isn't populated from the first time (all of them are empty) but after you just refresh the page data appears as it should.

This appears in RC2, in RC1 everything is perfect.
Below I put my code

Code: Select all

<p:dataTable 
            id="table"
            style="margin-bottom:30px"         
            value="#{bean.lazyModel}"
            var="bean" 
            lazy="true"
            dynamic="true"
            selectionMode="single"
            selection="#{{bean.selectedItem}"          
            paginator="true" 
            rows="10"
            paginatorPosition="bottom"
            paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
            rowsPerPageTemplate="5,10,15"           
            rowSelectListener="#{tenantBean.onRowSelect}"
And the bean lazy method is

Code: Select all

	public LazyDataModel<T> getLazyModel() {
		if (lazyModel == null) {
			lazyModel = createTableLazyModel();
		}

		lazyModel.setRowCount(editedItems.size() + pagingResultsCount);

		return lazyModel;
	}	
	
	protected LazyDataModel<T> createTableLazyModel(){
		return new LazyDataModel<T>() {

			@Override
			public List<T> load(int first, int pageSize,
					String sortField, boolean sortOrder, Map<String, String> filters) {

				tablePageSize = pageSize;

				if (sortField == null) {
					sortField = getDefaultSortProperty();
				}

				pagingResults = doFetchPagingResults(first, pageSize, sortField, sortOrder, filters);
				List<T> allItems = pagingResults.getRecords();
				pagingResultsCount = pagingResults.getTotal();

				List<T> itemsToReturn = new ArrayList<T>();
				
				if (!editedItems.isEmpty()) {
					itemsToReturn.addAll(editedItems);
					itemsToReturn.addAll(allItems);
					int lastIndex = pageSize;
					if (lastIndex > itemsToReturn.size()){
						lastIndex = itemsToReturn.size();
					}
					itemsToReturn = itemsToReturn.subList(0,
							lastIndex);
				} else {
					itemsToReturn.addAll(allItems);
				}

				setRowCount(pagingResultsCount + editedItems.size());

				currentItems = itemsToReturn;
				return itemsToReturn;
			}

		};		
	}
It's just a bit of code where the action is supposed to be. Moreover during debug I couldn't fine any difference between action performing on first load and after refresh.

Thanks

easyrider
Posts: 7
Joined: 22 Nov 2010, 21:14

25 Nov 2010, 17:33

Hi,

I've resolved it with some workaround - in the backing bean constructor I initially set rowCount of table model to some value greater than zero.
Without it I had the same symptoms as you have.

Hubert
PrimeFaces-2.2.RC2, Mojarra 2.0.3, Tomcat 6.0.26

substanceoflife
Posts: 9
Joined: 15 Nov 2010, 11:25

25 Nov 2010, 17:36

Thank you easyrider, I'll try that.

But it looks like kind of a bug

substanceoflife
Posts: 9
Joined: 15 Nov 2010, 11:25

26 Nov 2010, 10:36

I saw another posts where guys talked about the same problem. So maybe optimus know something about that should we get back to RC1 before this issue will be fixed.

tricky10
Posts: 79
Joined: 25 Oct 2010, 08:52
Location: Poland

27 Nov 2010, 14:18

Confirmed i have the same bug in RC2 i've posted an issue 1513. In RC1 everything is perfec. I will try to use a workaround but i this this should have the biggest priority.
Glassfish Application Server V3.1.2.2
Primefaces Library 3.5 FINAL
Sun Mojarra 2.1.20

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 43 guests