You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by ashindler <al...@hotmail.com> on 2014/07/15 16:37:09 UTC

Fileupload causes internet explorer 11 to hang

Hi,

I have the following code - with google chrome I experience no problems but
in internet explorer 11 the page hangs and gets stuck. I am using the latest
version of wicket. 

Any ideas?

Code summary:

                Form uploadForm = new Form("uploadForm");		
		uploadForm.setMultiPart(true);
		uploadForm.setMaxSize(Bytes.kilobytes(100));
		uploadForm.add(fileUpload = new FileUploadField("fileUpload"));
		
		uploadForm.add(new AjaxButton("upload", uploadForm){

			@Override
			public void onSubmit(AjaxRequestTarget target, Form uploadForm) {
				
				
				final FileUpload uploadedFile = fileUpload.getFileUpload();
				if (uploadedFile != null) {
	 
					// write to a new file
					File newFile = new File(UPLOAD_FOLDER
						+ uploadedFile.getClientFileName());
	 
					if (newFile.exists()) {
						newFile.delete();
					}
	 
					try {
						newFile.createNewFile();
						uploadedFile.writeTo(newFile);
	 
					} 
					catch (Exception e) {throw new IllegalStateException("Error");}
				}
				
				
				//Upload file to folder in my application
				String dataFileName = ((WebApplication)
Application.get()).getServletContext().getRealPath("/")+"WEB-INF\\classes\\ums\\app\\TransitMemshak\\memshak.txt";
				
				//Check if there is a file for upload
				File myFile = new File(dataFileName);
				if(!myFile.exists()){				
					informationDialog.setMessage("There is no file to upload!");
					informationDialog.show(target);
				}
				
				BufferedReader bReader;
				try {
					
					bReader = new BufferedReader(new FileReader(dataFileName));
				
					String line;
					while ((line = bReader.readLine()) != null) {
						
						//upload file code and logic	etc here
					}
					
					bReader.close();
					
					//Delete file
					if(myFile.exists())
					    myFile.delete();
									
				} 
				
				catch (FileNotFoundException e) {e.printStackTrace();}
				catch (IOException e) {e.printStackTrace();}
				catch (ClassNotFoundException e) {e.printStackTrace();}
				catch (SQLException e) {e.printStackTrace();}
				
			}
			@Override
			protected void onError(AjaxRequestTarget target, Form uploadForm) {
				errorDialog.setErrors(CommonTasks.errorDisplay(target, uploadForm));
				errorDialog.show(target);
			}
			
		});

		add(uploadForm);

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Fileupload-causes-internet-explorer-11-to-hang-tp4666619.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: Fileupload causes internet explorer 11 to hang

Posted by Sven Meier <sv...@meiers.net>.
Hi,

I've experienced strange problems with later IE versions, when they are 
forced to run under previous (i.e. non-edge) compatibility - up to the 
point that Ajax wasn't working at all :/.

A "X-UA-Compatible" response header is always safer to use than a meta 
tag, since the latter can/will be overwritten by IE depending on its 
settings and the position in the markup.

 >now it works fine

Great!

Sven

On 07/16/2014 07:56 AM, ashindler wrote:
> Hi Sven,
>
> I added this to my code and now it works fine:
>
> @Override
> 	protected void setHeaders(WebResponse response)
> 	{
> 	    response.setHeader("X-UA-Compatible", "IE=edge");
> 	}
>
> Thanks for pointing me in the right direction!
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Fileupload-causes-internet-explorer-11-to-hang-tp4666619p4666622.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
>


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


Re: Fileupload causes internet explorer 11 to hang

Posted by ashindler <al...@hotmail.com>.
Hi Sven,

I added this to my code and now it works fine:

@Override
	protected void setHeaders(WebResponse response) 
	{  
	    response.setHeader("X-UA-Compatible", "IE=edge");
	}

Thanks for pointing me in the right direction!

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Fileupload-causes-internet-explorer-11-to-hang-tp4666619p4666622.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: Fileupload causes internet explorer 11 to hang

Posted by ashindler <al...@hotmail.com>.
Hi Sven,

I am using 6.16.0.

Which X-UA-Compatible meta tag do you believe I should be using?

I tried with:

<meta http-equiv="X-UA-Compatible" content="IE=edge">

and

<meta http-equiv="X-UA-Compatible" content="IE=9">

in the header but I still experienced the hanging.

Like I mentioned in chrome I experience no problems at all so I don't
believe it is a problem with my java code.

Regards,

Alex

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Fileupload-causes-internet-explorer-11-to-hang-tp4666619p4666621.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: Fileupload causes internet explorer 11 to hang

Posted by Sven Meier <sv...@meiers.net>.
Hi,

which Wicket version? Are you using X-UA-Compatible meta tags?

Sven

On 07/15/2014 04:37 PM, ashindler wrote:
> Hi,
>
> I have the following code - with google chrome I experience no problems but
> in internet explorer 11 the page hangs and gets stuck. I am using the latest
> version of wicket.
>
> Any ideas?
>
> Code summary:
>
>                  Form uploadForm = new Form("uploadForm");		
> 		uploadForm.setMultiPart(true);
> 		uploadForm.setMaxSize(Bytes.kilobytes(100));
> 		uploadForm.add(fileUpload = new FileUploadField("fileUpload"));
> 		
> 		uploadForm.add(new AjaxButton("upload", uploadForm){
>
> 			@Override
> 			public void onSubmit(AjaxRequestTarget target, Form uploadForm) {
> 				
> 				
> 				final FileUpload uploadedFile = fileUpload.getFileUpload();
> 				if (uploadedFile != null) {
> 	
> 					// write to a new file
> 					File newFile = new File(UPLOAD_FOLDER
> 						+ uploadedFile.getClientFileName());
> 	
> 					if (newFile.exists()) {
> 						newFile.delete();
> 					}
> 	
> 					try {
> 						newFile.createNewFile();
> 						uploadedFile.writeTo(newFile);
> 	
> 					}
> 					catch (Exception e) {throw new IllegalStateException("Error");}
> 				}
> 				
> 				
> 				//Upload file to folder in my application
> 				String dataFileName = ((WebApplication)
> Application.get()).getServletContext().getRealPath("/")+"WEB-INF\\classes\\ums\\app\\TransitMemshak\\memshak.txt";
> 				
> 				//Check if there is a file for upload
> 				File myFile = new File(dataFileName);
> 				if(!myFile.exists()){				
> 					informationDialog.setMessage("There is no file to upload!");
> 					informationDialog.show(target);
> 				}
> 				
> 				BufferedReader bReader;
> 				try {
> 					
> 					bReader = new BufferedReader(new FileReader(dataFileName));
> 				
> 					String line;
> 					while ((line = bReader.readLine()) != null) {
> 						
> 						//upload file code and logic	etc here
> 					}
> 					
> 					bReader.close();
> 					
> 					//Delete file
> 					if(myFile.exists())
> 					    myFile.delete();
> 									
> 				}
> 				
> 				catch (FileNotFoundException e) {e.printStackTrace();}
> 				catch (IOException e) {e.printStackTrace();}
> 				catch (ClassNotFoundException e) {e.printStackTrace();}
> 				catch (SQLException e) {e.printStackTrace();}
> 				
> 			}
> 			@Override
> 			protected void onError(AjaxRequestTarget target, Form uploadForm) {
> 				errorDialog.setErrors(CommonTasks.errorDisplay(target, uploadForm));
> 				errorDialog.show(target);
> 			}
> 			
> 		});
>
> 		add(uploadForm);
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Fileupload-causes-internet-explorer-11-to-hang-tp4666619.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
>


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