Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

I'm confused about file uploading mechanism in richfaces

802204Jul 15 2008 — edited Jul 15 2008
I'm going to use <rich:fileUpload> to uploading files. This is some part of my backing bean named FileUploadBean:
private List data = new ArrayList();
public List getFileList () {
	    return data;
	}
	
	public void listener(UploadEvent event){
	    UploadItem item = event.getUploadItem();
	    System.out.println("File : '" + item.getFileName() + "' was uploaded");
	    if (item.isTempFile()) {
		File file = item.getFile();
		System.out.println("Absolute Path : '" + file.getAbsolutePath() + "'!");
		file.delete();
	    }else {
	    	try {
				ByteArrayOutputStream b = new ByteArrayOutputStream();
				b.write(item.getData());
				
				System.out.println(b.toString());
			} catch (Exception e) {
				e.printStackTrace();
			}
		
	    }
	}
	public String test(){
		if (getData() != null ){
			String test = getData().get(0).toString();
			System.out.println("Ausgeben:" + test );
		} 
		return null;
	}
And this is my jsf file named upload.jsp:
<h:form enctype="multipart/form-data">
            <rich:fileUpload fileUploadListener = "#{fileUploadBean.listener}"
				uploadData = "#{fileUploadBean.data}"
				listWidth = "#{fileUploadBean.width}" listHeight="#{fileUploadBean.height}"
				maxFilesQuantity = "#{fileUploadBean.maxFiles}"
                acceptedTypes = "*">
                <a4j:support event="onuploadcomplete" reRender="info" />
            </rich:fileUpload>
            <h:panelGroup id="info">
                <rich:panel bodyClass="info">
                    <f:facet name="header">
                        <h:outputText value="Uploaded Files Info" />
                    </f:facet>
  
                </rich:panel>
                <rich:spacer height="3"/>
                <br />
                <a4j:commandButton action = "#{fileUploadBean.test}"
                    reRender="info, upload" value="Clear Uploaded Data" />
            </h:panelGroup>
        
    </h:form>
When I do upload using this upload.jsf every thing is ok and at last I see message DONE and the lines below in console:
                File : 'D:\Documents and Settings\Admin\My Documents\My Pictures\1_java_logo.gif' was uploaded
	Absolute Path : 'D:\DOCUME~1\Admin\LOCALS~1\Temp\6a335dad-11b25ebea8d--800021601.upload'!
But I can't find any file anywhere in my computer and there is nothing in Uploaded Files panel. How can I control the destination of uploaded files? is there something wrong?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 12 2008
Added on Jul 15 2008
2 comments
713 views