TOPIC: Grundlegende Probleme mit XDevUpload-Komponente
1 year 3 weeks ago #485
Hallo,
Ich habe heute erstmals versucht die XDevUpload-Komponente in der GUI zu integrieren und bin auf einige Probleme gestossen. Als erstes ist es mir nicht gelungen den Receiver fuer die Komponente im Properties-View zu setzen, obwohl das Receiver-Interface in der GUI-Komponente selbst implementiert ist (der Eintrag war ausgegraut und daher nicht selektierbar). Verzweifelt habe ich dann die fehlenden Eintraege (setReceiver(this)) in der enter Methode der GUI-Komponente ergaenzt. Leider musste ich dann feststellen, dass die receiveUpload Methode nicht angesprungen wird (nach Button-Click in der GUI). Ursache ist die folgende Exception (der Wert beim ersten readLine im FileUploadHandler ist stets -1, unabhaengig von der selektierten Datei)
SEVERE: Servlet.service() for servlet [com.gsp.pertradat.ui.Servlet] in context with path [/PerTraDat] threw exception [com.vaadin.server.ServiceException: java.io.IOException: The multipart stream ended unexpectedly] with root cause
java.io.IOException: The multipart stream ended unexpectedly
	at com.vaadin.server.communication.FileUploadHandler.readLine(FileUploadHandler.java:302)
	at com.vaadin.server.communication.FileUploadHandler.doHandleSimpleMultipartFileUpload(FileUploadHandler.java:360)
	at com.vaadin.server.communication.FileUploadHandler.handleRequest(FileUploadHandler.java:285)
	at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1409)
	at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:364)
	at com.gsp.pertradat.ui.Servlet.service(Servlet.java:127)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)

Im folgenden der Code der GUI-Komponente (ohne Implementierung der Receiver-Interface Methoden, aber anhand von Breakpoints ist klar, dass sie nicht angesprungen werden)
package com.gsp.pertradat.ui;

import java.io.OutputStream;

import com.vaadin.navigator.ViewChangeListener;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.Upload.Receiver;
import com.vaadin.ui.Upload.SucceededEvent;
import com.vaadin.ui.Upload.SucceededListener;
import com.xdev.ui.XdevGridLayout;
import com.xdev.ui.XdevUpload;
import com.xdev.ui.XdevView;

public class PayrollUploadView extends XdevView implements Receiver, SucceededListener
{
	public PayrollUploadView() {
		super();
		this.initUI();
	}

	public void enter(ViewChangeListener.ViewChangeEvent event)
	{
		super.enter(event);
//		final FileReceiver uploader = new FileReceiver(); 
		uploadWorkplacePayroll.setReceiver(this);
		uploadWorkplacePayroll.addSucceededListener(this);
	}
	
	@Override
	public void uploadSucceeded(SucceededEvent event) {
		// TODO Auto-generated method stub
		event.getSource().getClass();
	}

	@Override
	public OutputStream receiveUpload(String filename, String mimeType) {
		// TODO Auto-generated method stub
		return null;
	}

	/*
	 * WARNING: Do NOT edit!<br>The content of this method is always regenerated
	 * by the UI designer.
	 */
	// <generated-code name="initUI">
	private void initUI() {
		this.gridLayout = new XdevGridLayout();
		this.uploadWorkplacePayroll = new XdevUpload();
	
		this.uploadWorkplacePayroll.setCaption("Workplace Timesheet For Upload");
	
		this.gridLayout.setColumns(2);
		this.gridLayout.setRows(2);
		this.uploadWorkplacePayroll.setSizeUndefined();
		this.gridLayout.addComponent(this.uploadWorkplacePayroll, 0, 0);
		CustomComponent gridLayout_hSpacer = new CustomComponent();
		gridLayout_hSpacer.setSizeFull();
		this.gridLayout.addComponent(gridLayout_hSpacer, 1, 0, 1, 0);
		this.gridLayout.setColumnExpandRatio(1, 1.0F);
		CustomComponent gridLayout_vSpacer = new CustomComponent();
		gridLayout_vSpacer.setSizeFull();
		this.gridLayout.addComponent(gridLayout_vSpacer, 0, 1, 0, 1);
		this.gridLayout.setRowExpandRatio(1, 1.0F);
		this.gridLayout.setSizeFull();
		this.setContent(this.gridLayout);
		this.setSizeFull();
	} // </generated-code>

	// <generated-code name="variables">
	private XdevUpload uploadWorkplacePayroll;
	private XdevGridLayout gridLayout; // </generated-code>
}
The administrator has disabled public write access.