You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by fachhoch <fa...@gmail.com> on 2010/12/21 02:19:06 UTC

famous ajaxuploadpanel

I am using the famous ajaxupload panel which uses IFrame to simulate ajax
fileupload.

till this time I was saving the uploaded file to database and  in
onUploadFinished  method I used to update a refreshingview which gets these
files from database .
Now  I want to save them in memory till the user saves the form which has  
some more  filelds  .
what I did is I created a simple object to represent uploaded file , this
object contains filename and filebytes .
My case is Panel which has a form and and  ajaxuploadpanel,the panel has
fields represting formelements model and Myobject represeting uploaded file.
my panel

public abstract class AbstractBatchPanel extends Panel {

	
	private BatchFileHelper  audBatchFileHelper;
	
	
	
	private Date  batchReceivedDate; 



My uploaded file  representing object  is below

	protected   class BatchFileHelper  implements  Serializable {
			String filename;
			byte[]  filedata;
			FileType  fileType;
			
			public BatchFileHelper(String filename, byte[]  filedata,  FileType 
fileType ) {
				this.filedata=filedata;
				this.filename=filename;
				this.fileType=fileType;
			}
			
	}



this is the simple class representing  uploaded file.

in the onFileUpload method of myUploadPanel  I create instance of  
BatchFileHelper   and set it to the field 
here is the code


		add(new UploadPanel("auditBatchUploadPnel") {
			
			@Override
			public void onUploadFinished(AjaxRequestTarget target, String filename,
					String newFileUrl) {
				
				System.out.println(AbstractBatchPanel.this.audBatchFileHelper);
				target.addComponent(AbstractBatchPanel.this.get("batchFilesContainer"));
			}
			@Override
			public String onFileUploaded(FileUpload upload) {
				if(upload!=null){
					AbstractBatchPanel.this.audBatchFileHelper= new
BatchFileHelper(FilenameUtils.getName(upload.getClientFileName()),upload.getBytes(),FileType.AUDIT);
				}
				return "";
			}
		});



I was assuming after onFileUploadedmethod  is called   the instance field   
audBatchFileHelper  will hold the uploaded file.but surprising once I
comeout of this method  in teh method onUploadFinished the   
audBatchFileHelper   remanins null.
Please help me, tell me why is the instance field remain null   even after 
instantiating   ?









-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/famous-ajaxuploadpanel-tp3113809p3113809.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: famous ajaxuploadpanel

Posted by Pedro Santos <pe...@gmail.com>.
please provide a quickstart

On Mon, Dec 20, 2010 at 11:19 PM, fachhoch <fa...@gmail.com> wrote:

>
> I am using the famous ajaxupload panel which uses IFrame to simulate ajax
> fileupload.
>
> till this time I was saving the uploaded file to database and  in
> onUploadFinished  method I used to update a refreshingview which gets these
> files from database .
> Now  I want to save them in memory till the user saves the form which has
> some more  filelds  .
> what I did is I created a simple object to represent uploaded file , this
> object contains filename and filebytes .
> My case is Panel which has a form and and  ajaxuploadpanel,the panel has
> fields represting formelements model and Myobject represeting uploaded
> file.
> my panel
>
> public abstract class AbstractBatchPanel extends Panel {
>
>
>        private BatchFileHelper  audBatchFileHelper;
>
>
>
>        private Date  batchReceivedDate;
>
>
>
> My uploaded file  representing object  is below
>
>        protected   class BatchFileHelper  implements  Serializable {
>                        String filename;
>                        byte[]  filedata;
>                        FileType  fileType;
>
>                        public BatchFileHelper(String filename, byte[]
>  filedata,  FileType
> fileType ) {
>                                this.filedata=filedata;
>                                this.filename=filename;
>                                this.fileType=fileType;
>                        }
>
>        }
>
>
>
> this is the simple class representing  uploaded file.
>
> in the onFileUpload method of myUploadPanel  I create instance of
> BatchFileHelper   and set it to the field
> here is the code
>
>
>                add(new UploadPanel("auditBatchUploadPnel") {
>
>                        @Override
>                        public void onUploadFinished(AjaxRequestTarget
> target, String filename,
>                                        String newFileUrl) {
>
>
>  System.out.println(AbstractBatchPanel.this.audBatchFileHelper);
>
>  target.addComponent(AbstractBatchPanel.this.get("batchFilesContainer"));
>                        }
>                        @Override
>                        public String onFileUploaded(FileUpload upload) {
>                                if(upload!=null){
>
>  AbstractBatchPanel.this.audBatchFileHelper= new
>
> BatchFileHelper(FilenameUtils.getName(upload.getClientFileName()),upload.getBytes(),FileType.AUDIT);
>                                }
>                                return "";
>                        }
>                });
>
>
>
> I was assuming after onFileUploadedmethod  is called   the instance field
> audBatchFileHelper  will hold the uploaded file.but surprising once I
> comeout of this method  in teh method onUploadFinished the
> audBatchFileHelper   remanins null.
> Please help me, tell me why is the instance field remain null   even after
> instantiating   ?
>
>
>
>
>
>
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/famous-ajaxuploadpanel-tp3113809p3113809.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Pedro Henrique Oliveira dos Santos