1
I’m using the latest version of Richfaces, I copied the example of show case on the Richfaces website, and the example does not invoke the Istener, I’ve tried everything, someone could help me?
xhtml
<rich:fileUpload fileUploadListener="#{fileUploadBean.listener}"
id="upload" acceptedTypes="jpg, gif, png, bmp"
maxFilesQuantity="5">
<a4j:ajax event="uploadcomplete" execute="@none" render="info" />
</rich:fileUpload>
Bean
@ManagedBean
@SessionScoped
public class FileUploadBean implements Serializable {
private ArrayList<UploadedImage> files = new ArrayList<UploadedImage>();
public void paint(OutputStream stream, Object object) throws IOException {
stream.write(getFiles().get((Integer) object).getData());
stream.close();
}
public void listener(FileUploadEvent event) throws Exception {
System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& - LISTENER");
UploadedFile item = event.getUploadedFile();
UploadedImage file = new UploadedImage();
//file.setLength(item.getData().length);
file.setName(item.getName());
file.setData(item.getData());
files.add(file);
}
public String clearUploadData() {
files.clear();
return null;
}
public int getSize() {
if (getFiles().size() > 0) {
return getFiles().size();
} else {
return 0;
}
}
public long getTimeStamp() {
return System.currentTimeMillis();
}
public ArrayList<UploadedImage> getFiles() {
return files;
}
public void setFiles(ArrayList<UploadedImage> files) {
this.files = files;
}
}
Web.xml
<context-param>
<param-name>org.richfaces.fileUpload.maxRequestSize</param-name>
<param-value>10000000</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.fileUpload.createTempFiles</param-name>
<param-value>true</param-value>
</context-param>