For <rich:fileUpload>
I'm unable to invoke listener
. When I checked in firebug console I found that its going in infinite GET
requests loop.
web.xml:
<context-param>
<param-name>org.richfaces.fileUpload.maxRequestSize</param-name>
<param-value>1000000000</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.fileUpload.createTempFiles</param-name>
<param-value>false</param-value>
</context-param>
Facelet:
<h:form enctype="multipart/form-data">
<rich:fileUpload fileUploadListener="#{fileUploadController.listener}" id="upload" acceptedTypes="jpg, gif, png, bmp"
ontyperejected="alert('Only JPG, GIF, PNG and BMP files are accepted');" maxFilesQuantity="5">
<a4j:ajax event="uploadcomplete" execute="@none" render="info" />
</rich:fileUpload>
</h:form>
Backing Bean:
public void listener(FileUploadEvent event) throws Exception{
UploadedFile item = event.getUploadedFile();
uploadFile.setLength(item.getData().length);
uploadFile.setName(item.getName());
uploadFile.setData(item.getData());
writeFile();
}
public void writeFile() {
FileOutputStream fop = null;
File file;
try {
file = new File(fPath + uploadFile.getName());
logger.info(fPath + uploadFile.getName());
fop = new FileOutputStream(file);
if (!file.exists()) {
file.createNewFile();
}
fop.write(uploadFile.getData());
fop.flush();
fop.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (fop != null) {
fop.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
I checked a lot of similar questions but didn't got any clue !
I'm using RichFaces version 4.2.2
You can try to remove following lines form your web.xml, somebody fix by doing that.
<filter>
<filter-name>Seam Multipart Filter</filter-name>
<filter-class>org.jboss.seam.web.MultipartFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Seam Multipart Filter</filter-name>
<url-pattern>*.seam</url-pattern>
</filter-mapping>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.