上传页面:
uploadListener方法:
public void uploadListener(FileUploadEvent event) {
UploadedFile item = event.getUploadedFile();
List<DirExpBudget> tmpList = new ArrayList<DirExpBudget>();
setListDirExpBudget(new ArrayList<DirExpBudget>());
try {
Workbook workbook = null;
try {
workbook = Workbook.getWorkbook(item.getInputStream());
} catch (BiffException e) {
procException(e, "得到Excel");
return;
} catch (IOException e) {
procException(e, "得到Excel");
return;
}
Sheet[] sheets = workbook.getSheets(); // 获取所有sheet页
for (int n = 0; n < sheets.length; n++) {
Sheet sheet = sheets[n];
int row = sheet.getRows(); // 获取信息总行数
if (sheet.getCell(0, 1).getContents().split(":").length <= 1) {
setAlertMessage("第" + (n + 1) + "个sheet页,部门名称不存在,请检查!");
return;
}
String bmmc = sheet.getCell(0, 1).getContents().split(":")[1]
.trim(); // 获取部门名称
String conditionDept = " entity.deptName = '" + bmmc
+ "' AND entity.deptType = '01'";
if (sheet.getCell(6, 1).getContents().split(":").length <= 1) {
setAlertMessage("第" + (n + 1) + "个sheet页,科目名称不存在,请检查!");
return;
}
.......
for (int j = 5; j < row; j++) { // j 行
dirExpBudget = new DirExpBudget();
......
tmpList.add(dirExpBudget);
}
}
} catch (NumberFormatException e) {
procException(e, "导入");
return;
}
if (tmpList == null || tmpList.size() == 0) {
return;
}
getListDirExpBudget().addAll(tmpList);
}
当导入的Excel超过10个sheet页时,导入页面显示如下:
检查Console中,好像执行了两遍 uploadListener这个方法。
跪求大神 指点!!!!!
------解决方案--------------------
uploadListener 这是用的观察者模式。
rich:messages 会在页面中显示所有消息:
<rich:popupPanel id="messagePopup" left="500" top="20" show="true" modal="false" >
<rich:messages id="mess" />
</rich:popupPanel>
你加上特定组件试试:
FacesContext faceContext = FacesContext.getCurrentInstance();
FacesMessage facesMessage = new FacesMessage();
facesMessage.setSeverity(FacesMessage.SEVERITY_ERROR);
facesMessage.setDetail(this.ppsResources.getString("passwordupdated"));