-
1. Re: I'm confused about file uploading mechanism in richfaces
janson12 Jul 16, 2008 5:44 AM (in response to laura_jlover)this is how you call it from within your upload tag:
fileUploadListener="#{targetBean.uploaded}"
and this is the method in your bean:
private byte[] xmlContent; private UploadItem uploadedItem; .... /** * listener that is called after a file has been uploaded */ public void uploaded(UploadEvent ae) { /* fetching the uploaded file */ this.uploadedItem = ae.getUploadItem(); this.xmlContent = this.uploadedItem.getData(); this.fileName = this.uploadedItem.getFileName(); .... }
-
2. Re: Re: I'm confused about file uploading mechanism in richf
laura_jlover Jul 16, 2008 1:15 PM (in response to laura_jlover)Thanks, but I can't know how to determine the location which uploaded file will save over there. Assume that I would like save uploaded file/s in C:\upload could you please help me to do this?
Laura -
3. Re2: Re: I'm confused about file uploading mechanism in rich
laura_jlover Jul 17, 2008 11:35 AM (in response to laura_jlover)Now I can save your byte array as a file on my disk but the saved file is a 0KB file! what's wrong with my code?
-
4. Re3: Re: I'm confused about file uploading mechanism in rich
laura_jlover Jul 18, 2008 9:26 AM (in response to laura_jlover)Now I can save uploaded files completely. But I have some questions:
1. I see a filter named SleepDemoFilter in upload demo at jboss.com, what is it doing?
2. I see this listing in the code of demo, what is it doing?
if (item.isTempFile()) {
File file = item.getFile();
System.out.println("Absolute Path : '" + file.getAbsolutePath()
+ "'!");
file.delete();
} else { ...
3. I use the code of demo but after first upload my IE 7 still works (It's icon circulate) but when I do upload another file/s my browser will stop completely after upload. -
5. Re: I'm confused about file uploading mechanism in richfaces
chrix64 Dec 5, 2008 10:13 AM (in response to laura_jlover)Hello,
I have the same question and could not find any answer yet. Could anyone provide simple but complete code on how to get the data back after file upload for both methods (getData and getFile) ?
Thanks ! -
6. Re: I'm confused about file uploading mechanism in richfaces
nbelaevski Dec 5, 2008 1:29 PM (in response to laura_jlover)Hi,
data is an array of bytes that contain uploaded data for the file. file is java.io.File that you handle in a usual way: read it, copy or delete. Use isTempFile() to select proper method.