file not saved with ice:inputFile?
[Logo]
ICEsoft.org Forums: ICEfaces, ICEmobile, ICEpdf
[Search] Search   [Recent Topics] Recent Topics   [Groups] Home Page | www.icefaces.org  [Register] Register  [Login] Login 
file not saved with ice:inputFile?  XML
Forum Index -> JBoss Seam Integration
Author Message
leonbnu

Joined: 19/05/2009 00:00:00
Messages: 16
Offline


my testing case is almost the same as the example in icefaces-seam-component show case. But somehow the file did not get saved on the disk. I logged the absolute directory path of the file saved. I'm using Icefaces 1.8.1 and seam 2.1.2.

Here is my code.

testinputfile.xhtml
Code:
 <ice:form>
 	<ice:inputFile actionListener="#{inputFileController.uploadFile}" 
    									progressListener="#{inputFileController.fileuploadProgress}" 
    									uploadDirectoryAbsolute="false"
    									submitOnUpload="none" />
     <ice:outputProgress  value="#{inputFileController.progress}" ></ice:outputProgress>
    					
 </ice:form>
 


InputFileController:
Code:
 @Name("inputFileController")
 @Scope(ScopeType.SESSION)
 public class InputFileController implements Serializable{
 	
 	@Logger private Log log;
 	
 	
 	
 	// File sizes used to generate formatted label
     public static final long MEGABYTE_LENGTH_BYTES = 1048000l;
     public static final long KILOBYTE_LENGTH_BYTES = 1024l;
     
    
     // files associated with the current user
     
     private final List<InputFileData> fileList =
             Collections.synchronizedList(new ArrayList<InputFileData>());
     // latest file uploaded by client
     private InputFileData currentFile;
 	
     
     private String parentDirectory="";
     
     private int progress;
     
     public void uploadFile(ActionEvent event){
     	InputFile inputFile= (InputFile)event.getSource();
     	log.info("uploadFile has been called. Status: "+inputFile.getFileInfo().getStatus());
     	
     	
     	if(inputFile.getFileInfo().getStatus()==inputFile.SAVED){
     		
     		if(this.parentDirectory.equals("")){
     			this.parentDirectory = inputFile.getFile().getParent();
     		}
     		log.info("the absolute path of the uploaded file is " + inputFile.getFile().getAbsolutePath());
     		InputFileData currentFile =  new InputFileData(inputFile.getFileInfo());
         	
         	
         	synchronized (fileList) {
             	if (!listContains(currentFile.getFile().getName())){
             		//only add the file to the list if it isn't already there
             		//fileupload will just update a more recent version of the file
                     fileList.add(currentFile);
             	}
             }
     		
     	}
     	
     	
     		
     	
     }
 
 public void fileuploadProgress(EventObject event){
     	InputFile ifile = (InputFile) event.getSource();
         progress = ifile.getFileInfo().getPercent();
     	
     } 
 
 @BypassInterceptors
     public int getProgress(){
     	return progress;
     	
     }
 }


and no exception popped up. The progress bar works, just the file is not there.
judy.guglielmin

Joined: 20/02/2007 00:00:00
Messages: 1196
Offline


When you are stating that your file was not "saved", did you actually check the server location that you have designated/specified for the upload area? (from web.xml). Or are you simply referring to a listing you may have on your facelets page? (which might just be a result of the last "push" after the file is uploaded not occuring and you would set submitOnUpload="postUpload" for).

In your backing bean, you could always put an "else" statement to see what the status of the inputFile is. (if it's not SAVED).

leonbnu

Joined: 19/05/2009 00:00:00
Messages: 16
Offline


judy.guglielmin wrote:
When you are stating that your file was not "saved", did you actually check the server location that you have designated/specified for the upload area? (from web.xml). Or are you simply referring to a listing you may have on your facelets page? (which might just be a result of the last "push" after the file is uploaded not occuring and you would set submitOnUpload="postUpload" for).

In your backing bean, you could always put an "else" statement to see what the status of the inputFile is. (if it's not SAVED).

 


Sorry for the confusion. I meant that the file data is not retained on the disk. I specified "/upload/" as the directory in the web.xml. but somehow the directory is always empty. And the status inputFile gives to me is SAVED.

My facelets page is rather simple, no attempt to display the list of the uploaded files.

thanks
judy.guglielmin

Joined: 20/02/2007 00:00:00
Messages: 1196
Offline


Did you deploy seam-comp-showcase and see whether the file is uploaded to your server with it? (which application server?)
leonbnu

Joined: 19/05/2009 00:00:00
Messages: 16
Offline


judy.guglielmin wrote:
Did you deploy seam-comp-showcase and see whether the file is uploaded to your server with it? (which application server?) 


no, but I will give it a try. I'm using Jboss AS 5.1

thanks,
leonbnu

Joined: 19/05/2009 00:00:00
Messages: 16
Offline


Yes, the showcase works. The file data is saved properly. Now I have to find out what's wrong with my code.
 
Forum Index -> JBoss Seam Integration
Go to:   
Powered by JForum 2.1.7ice © JForum Team