I'm using primeface extensions (version 6.2) and started using the Sheet component. I upload an excel file, parse it, create objects based off this data, then add it to a list which is the object i used for the value property of the sheet. Everything was working fine until recently. Problem is after the method that does all the parsing, creating objects, etc. is done and the sheet is update, no data is shown and the headers even disappear. Anyone know what the problem is?
Here is the component for the fileuploader, sheet and the method that does the magic
<p:fileUpload
id="excelUploader"
mode="advanced"
value="#{excelDemoBean.file}"
invalidSizeMessage="Please upload file within file size limits"
sizeLimit="104857600"
process="@this"
update=":#{p:component('sheet')}"
fileUploadListener="#{excelDemoBean.handleFileUpload}"
allowTypes="/(\.|\/)(xls|xlsx)$/i">
</p:fileUpload>
<pe:sheet
id="sheet"
widgetVar="sheetWidget"
value="#{excelDemoBean.wpList}"
var="row"
rowKey="#{row.id}"
height="400"
fixedCols="2"
stretchH="all"
showRowHeaders="true"
resizableCols="true"
resizableRows="true"
sortOrder="ascending"
readOnly="false">
<f:facet name="header">
<h:outputText value="Uploaded Excel File" />
</f:facet>
<pe:sheetcolumn
headerText="Name"
value="#{row.name}"
sortBy="#{row.name}"
colWidth="150"
filterBy="#{row.name}" />
<pe:sheetcolumn
headerText="DCMS ID"
value="#{row.associatedLegacyProduct.leagcyProductId}"
colWidth="100"
sortBy="#{row.associatedLegacyProduct.leagcyProductId}"
filterBy="#{row.associatedLegacyProduct.leagcyProductId}"
colType="dropdown"
readOnly="true" />
<pe:sheetcolumn
headerText="FP Product Name"
value="#{row.fpProductName}"
colWidth="100"
sortBy="#{row.fpProductName}"
filterBy="#{row.fpProductName}"
colType="autocomplete"
autoCompleteStrict="false"
autoCompleteVisibleRows="4" />
<pe:sheetcolumn
headerText="PID"
value="#{row.processInstanceId}"
readOnly="true"
colWidth="100"
sortBy="#{row.processInstanceId}"
filterBy="#{row.processInstanceId}" />
<pe:sheetcolumn
headerText="Issuer"
value="#{row.issuer}"
colWidth="100" />
<pe:sheetcolumn
headerText="Processor"
value="#{row.processor}"
colWidth="100" />
<pe:sheetcolumn
headerText="Product Line"
value="#{row.productLine}"
colWidth="100" />
<pe:sheetcolumn
headerText="UPC"
value="#{row.upc}"
colWidth="100"
colType="numeric" />
<pe:sheetcolumn
headerText="Requester"
value="#{row.requester}"
colWidth="100" />
<pe:sheetcolumn
headerText="Country"
value="#{row.country}"
colWidth="100" />
<pe:sheetcolumn
headerText="Date Approved"
value="#{row.dateApproved}"
colWidth="100" />
<pe:sheetcolumn
headerText="Date Requested"
value="#{row.dateRequested}"
colWidth="100" />
</pe:sheet>
public void handleFileUpload(FileUploadEvent event) {
UploadedFile excelFile = event.getFile();
SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy hh:mm a");
Random rand = new Random();
if (StringUtils.equalsIgnoreCase(FilenameUtils.getExtension(excelFile.getFileName()), "xls")) {
File tempFileForUploadedExcelFile = File.createTempFile("tempCopyOfExcel", ".xls");
FileUtils.copyInputStreamToFile(excelFile.getInputstream(), tempFileForUploadedExcelFile);
FileInputStream inputStreamForTempFile = new FileInputStream(tempFileForUploadedExcelFile);
HSSFWorkbook workbook = new HSSFWorkbook(inputStreamForTempFile);
HSSFSheet sheet = workbook.getSheetAt(0);
Iterator<Row> rowIterator = sheet.rowIterator();
WorkflowProduct temp;
wpList = new ArrayList<>();
while (rowIterator.hasNext()) {
Row row = rowIterator.next();
if (row.getRowNum() != 0) {
temp = new WorkflowProduct();
Iterator<Cell> cellIterator = row.cellIterator();
temp.setName(cellIterator.next().getStringCellValue());
temp.setFpProductName(cellIterator.next().getStringCellValue());
temp.setProcessInstanceId(cellIterator.next().getStringCellValue());
temp.setIssuer(cellIterator.next().getStringCellValue());
temp.setProductLine(cellIterator.next().getStringCellValue());
temp.setProcessor(cellIterator.next().getStringCellValue());
temp.setUpc(cellIterator.next().getStringCellValue());
temp.setRequester(cellIterator.next().getStringCellValue());
temp.setCreator(cellIterator.next().getStringCellValue());
temp.setApprover(cellIterator.next().getStringCellValue());
String date1 = cellIterator.next().getStringCellValue();
String date2 = cellIterator.next().getStringCellValue();
temp.setDateApproved(format.parse(date1));
temp.setDateRequested(format.parse(date2));
temp.setCountry(cellIterator.next().getStringCellValue());
temp.setClassification(cellIterator.next().getStringCellValue());
temp.setType(cellIterator.next().getStringCellValue());
temp.setDenomType(cellIterator.next().getStringCellValue());
temp.setDenomValue(cellIterator.next().getStringCellValue());
temp.setFpProductLine(cellIterator.next().getStringCellValue());
temp.setFpProductType(cellIterator.next().getStringCellValue());
String value = cellIterator.next().getStringCellValue();
temp.setFpProductCode(StringUtils.isBlank(value) ? 0 : Integer.parseInt(value));
temp.setId(rand.nextInt());
wpList.add(temp);
}
}
Files.delete(tempFileForUploadedExcelFile.toPath());
inputStreamForTempFile.close();
workbook.close();
}