uploadfile fileUploadListener dons't work
dance Oct 11, 2011 9:14 PMthe question is just the title.
my view code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
template="/WEB-INF/templates/default.xhtml">
<ui:define name="content">
<h:body>
<h:form enctype="multipart/form-data">
<rich:fileUpload id="upload"
fileUploadListener="#{fileUpload.listener}"
maxFilesQuantity="#{fileUpload.uploadsAvailable} "
acceptedTypes="png" noDuplicate="true" />
</h:form>
</h:body>
</ui:define>
</ui:composition>
and my controller code:
package upload.upload.controller;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import javax.enterprise.inject.Model;
import org.richfaces.event.FileUploadEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import upload.upload.model.File;
@Model
public class FileUpload {
private static final Logger log = LoggerFactory.getLogger(FileUpload.class);
private ArrayList<File> files = new ArrayList<File>();
private int uploadsAvailable = 5;
private boolean autoUpload = true;
private boolean useFlash = false;
public FileUpload() {
super();
}
public int getSize() {
if (getFiles().size() > 0) {
return getFiles().size();
} else {
return 0;
}
}
public void listener(final FileUploadEvent event) throws Exception {
log.info("listener");
}
public void paint(OutputStream stream, Object object) throws IOException {
stream.write(getFiles().get((Integer) object).getData());
}
public long getTimeStamp() {
return System.currentTimeMillis();
}
...
}
anyone had this problem?