problem with data exporter in Primefaces 2.2.1

UI Components for JSF
Post Reply
dgeorge
Posts: 16
Joined: 11 Jan 2011, 14:49

23 Mar 2011, 16:47

Hi

I am using the primeFaces 2.2.1

I am using Primefaces 2.2.1 with jsf 2.0, and using dataExporter component along with with lazyDataModel in "DataTable".

if I set the attribute of dataExporter component to "pageOnly=true" , Then i'm getting exception .:"Caused by: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'tableEntity' resolved to null"

After debugging I found out that, if the pageOnly is set to true, size is setting from pagesize of datatable.
Suppose I have set the pagesize of datatable to 10. (in lazyDataModel setPageSize()). But I have only 5 record.(Only 5 rows). If i do a export , "pageOnly=true", then I'm getting exception in ExcelExporter.class(lineno: 97).

In ExcelExporter.class line no: 49, ie

Code: Select all

int size = pageOnly ? (first + table.getRows()) : table.getRowCount();
size is setting from getRows(). Rows is setting from pagesize of lazyDataModel pagesize. I'm getting 10 as size in this line.
So it will loop for 10 times. But I have only 5 rows.

Code: Select all

for(int i = first; i < size; i++) {            //size is 10
    		table.setRowIndex(i);
			HSSFRow row = sheet.createRow(sheetRowIndex++);
			
			for (int j = 0; j < numberOfColumns; j++) {
				UIColumn column = columns.get(j);
				
				if(column.isRendered())
					addColumnValue(row, column.getChildren(), j);
			}
		}
Here 5th time. it will call addColumnValue(), which will through tableEntity resolve to null error. In the ExcelExporter.class


Expected result : it should export my page.
Changes to do the code to work:
In ExcelExporter.class You should have a check to know whether the rowCount is less than the pagesize. If it is less then it should take rowcount for size. ie if(table.getRowCount() < table.getRows())

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 53 guests