No file selection window with immediate upload

When using the upload component in immediate mode I face some strange behaviour. I don’t get the file selection dialog opened up when using Firefox 3.6 or Opera 10.10. With Internet Explorer 8, Chrome 4 or Safari 4 it is working perfectly. Does anyone have an idea on this?

For me, both browsers work at least on
http://demo.vaadin.com/sampler/#ImmediateUpload
.

Which Vaadin version are you using?
Can you provide a little example demonstrating the problem if the above mentioned demo works but your case doesn’t?

You are right. The demo also works for me in all browsers.

So I decided to strip down the code in a test project and figured out that having the Upload component in a FormLayout as a Tab in a TabSheet shows this behaviour. Just the FormLayout with contained Upload component is working and when I put the ProgressIndicator and the Upload component in an additional VerticalLayout it is also working in FormLayout in a TabSheet.

Here some code:


public class TestWindow extends Window implements StartedListener,
		ProgressListener, SucceededListener, FailedListener, FinishedListener,
		Receiver {

	private static Logger logger = LoggerFactory.getLogger(TestWindow.class);

	private ProgressIndicator progress = new ProgressIndicator();
	private Upload upload = new Upload(null, this);

	public TestWindow() {
		TabSheet tabSheet = new TabSheet();
		setContent(tabSheet);
		
		FormLayout layout = new FormLayout();

//		VerticalLayout innerLayout = new VerticalLayout();
		progress.setVisible(false);
		layout.addComponent(progress);
//		innerLayout.addComponent(progress);

		upload.setImmediate(true);
		upload.setButtonCaption("Choose Template");
		upload.addListener((StartedListener) this);
		upload.addListener((ProgressListener) this);
		upload.addListener((FailedListener) this);
		upload.addListener((SucceededListener) this);
		upload.addListener((FinishedListener) this);
		layout.addComponent(upload);
//		innerLayout.addComponent(upload);
		
//		layout.addComponent(innerLayout);
		tabSheet.addTab(layout, "Test", null);
	}

	@Override
	public void uploadStarted(StartedEvent event) {
		upload.setVisible(false);
		progress.setValue(0f);
		progress.setPollingInterval(500);
		progress.setVisible(true);
		logger.debug("Upload started...");
	}

	@Override
	public void updateProgress(long readBytes, long contentLength) {
		progress.setValue(new Float(readBytes / (float) contentLength));
	}

	@Override
	public void uploadSucceeded(SucceededEvent event) {
		logger.debug("Upload succeeded...");
	}

	@Override
	public void uploadFailed(FailedEvent event) {
		logger.debug("Upload failed...");
	}

	@Override
	public void uploadFinished(FinishedEvent event) {
		upload.setVisible(true);
		progress.setVisible(false);
		logger.debug("Upload finished...");
	}

	@Override
	public OutputStream receiveUpload(String filename, String MIMEType) {
		try {
			return new FileOutputStream("Test.txt");
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		return null;
	}
}

When adding Upload and ProgressIndicator to the additional “innerLayout” (which is commented out in the code above) instead of adding it to layout directly it is working. So I’ve got my fix. Perhaps someone is able to explain the behaviour. Would be interesting to know.

BTW: I was using Vaadin 6.2.5 and also tried 6.2.6 now.

Thanks a lot…

Created a
ticket
for this with a simplified test case and fixed in the Vaadin 6.3 branch.

That’s great… Thank you!