arrayList
ページ上の要素を表示しようとしていxhtml
ますが、新しいファイルをアップロードするたびに、ステータスページで、配列に存在するすべての要素の詳細ではなく、最後にアップロードされたファイルの複数のエントリを取得します。
これがコードです
XHTMLコード:
<ace:dataTable id ="archiveResults" resizableColumns="true" paginatorPosition="bottom" paginator="true" page="1" value="${fileUpload.resultBeanList}" var="result">
<ace:column id="fileUploadFileName" headerText="uploaded file" sortBy="#{result.fileName}" filterBy="#{result.fileName}" filterMatchMode="contains">
<h:outputFormat id="cellFileUploadFileName" value="${result.fileName}" />
</ace:column>
<ace:column id="fileUploadTime" headerText="time run" sortBy="#{result.timeRun}" filterBy="#{result.timeRun}" filterMatchMode="contains">
<h:outputFormat id="cellFileUploadTime" value="${result.timeRun}" />
</ace:column>
<ace:column id="fileUploadJobType" headerText="job type" sortBy="#{result.jobType}" filterBy="#{result.jobType}" filterMatchMode="contains">
<h:outputFormat id="cellFileUploadJobType" value="${result.jobType}" />
</ace:column>
<ace:column id="fileUploadStatus" headerText="Status" sortBy="#{result.status}" filterBy="#{result.status}" filterMatchMode="contains">
<h:outputFormat id="cellFileUploadStatus" value="${result.status}" />
</ace:column>
</ace:dataTable>
Javaコード:
private List<ResultBean> resultBeanList = new ArrayList<ResultBean>();
private ResultBean resultBean = new ResultBean();
public ResultBean getResultBean() {
return resultBean;
}
public void setResultBean(ResultBean resultBean) {
this.resultBean = resultBean;
}
public List<ResultBean> getResultBeanList() {
System.out.println("resultBeanList: "+resultBeanList.toString());
return resultBeanList;
}
public void setResultBeanList(List<ResultBean> resultBeanList) {
this.resultBeanList = resultBeanList;
}
public void uploadFile(FileEntryEvent event) {
FileEntry fileEntry = (FileEntry) event.getSource();
FileEntryResults results = fileEntry.getResults();
FileEntry fe = (FileEntry) event.getComponent();
FacesContext ctx = FacesContext.getCurrentInstance();
FacesMessage msg = new FacesMessage();
for (FileEntryResults.FileInfo fileInfo : results.getFiles()) {
if (fileInfo.isSaved()) {
File file = fileInfo.getFile();
String filePath = file.getAbsolutePath();
resultBean.setStatus(fileInfo.getStatus().toString());
resultBean.setFileName(fileInfo.getFileName());
resultBean.setJobType(selectedItem);
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date date = new Date();
Calendar cal = Calendar.getInstance();
dateFormat.format(cal.getTime());
resultBean.setTimeRun(dateFormat.format(cal.getTime()));
}
resultBeanList.add(resultBean);
}
}