我正在尝试使用多个af:inputFile组件创建多个文件上传。这是我的xhtml:
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<f:view>
<af:document id="d1" title="Home">
<af:form id="f1" usesUpload="true">
<af:commandButton text="Add" immediate="true"
actionListener="#{viewScope.massUpload.add}"
id="cb2"/>
<af:panelGroupLayout layout="vertical" id="pgl1" partialTriggers="cb1">
<af:iterator value="#{viewScope.massUpload.fileComponents}" var="fileComponent"
id="i1" varStatus="status">
<af:inputFile binding="#{fileComponent}" id="if1"
value="#{viewScope.massUpload.files[status.index]}"/>
</af:iterator>
<af:commandButton text="Upload"
actionListener="#{viewScope.massUpload.upload}"
id="cb1"/>
</af:panelGroupLayout>
</af:form>
</af:document>
</f:view>
</jsp:root>
这是托管bean:
package com.edfx.massupload.bean;
import java.util.ArrayList;
import java.util.List;
import javax.faces.event.ActionEvent;
import oracle.adf.view.rich.component.rich.input.RichInputFile;
import oracle.stellent.ridc.IdcClientException;
import org.apache.myfaces.trinidad.model.UploadedFile;
public class MassUploadBean {
private List<RichInputFile> fileComponents = new ArrayList<RichInputFile>();
private List<UploadedFile> files = new ArrayList<UploadedFile>();
public MassUploadBean() {
super();
}
public void add(ActionEvent event) {
fileComponents.add(new RichInputFile());
files.add(null);
}
public void upload(ActionEvent event) throws IdcClientException {
for(UploadedFile file : files) {
System.out.println(file.getFilename());
}
}
public void setFiles(List<UploadedFile> files) {
this.files = files;
}
public List<UploadedFile> getFiles() {
return files;
}
public void setFileComponents(List<RichInputFile> fileComponents) {
this.fileComponents = fileComponents;
}
public List<RichInputFile> getFileComponents() {
return fileComponents;
}
}
我面临的问题是:
我做错了吗?任何指针都会非常有用。
答案 0 :(得分:1)
我看到你正在使用IdcClientException告诉我你正在上传到UCM。如果您还使用WebCenter,那么您可以使用随WebCenter Portal附带的现成上载任务流:http://docs.oracle.com/cd/E29597_01/webcenter.1111/e25595/jpsdg_content_jsfpg.htm#autoId18
从PS5开始,任务流将为您执行多文件上传。
答案 1 :(得分:1)
以后版本的ADF应该有助于批量上传: http://jdevadf.oracle.com/adf-richclient-demo/docs/tagdoc/af_inputFile.html
启用displayMode和maximumFiles(另请参阅uploadType)。