Hi,
I have problem using upload component in portlets with Liferay.
I’m using Vaadin 6.5.2 and Liferay 6.0.5.
My form is printed well but when i click on upload button after having selected a file, my liferay page is refreshed and nothing happens.
uploadFinished… methods are never called (no log in console).
I just want to retrieve bytes array that the user sent to the server.
Does anybody have some to code to share that worked in liferay context ?
Is there a configuration in Liferay that can blocks my upload ?
protected void MyComponent() throws Exception {
myReceiver = new MyReceiver();
upload = new Upload("Upload", myReceiver);
constructionUpload();
this.addComponent(upload);
}
private void constructionUpload() {
upload.setButtonCaption("Envoyer");
upload.addListener(new Upload.FinishedListener() {
private static final long serialVersionUID = 1L;
@Override
public void uploadFinished(FinishedEvent event) {
ByteArrayOutputStream os = myReceiver.getBos();
os.toByteArray();
System.out.println("upload finish !!");
}
});
upload.addListener(new Upload.SucceededListener() {
private static final long serialVersionUID = 1L;
@Override
public void uploadSucceeded(SucceededEvent event) {
System.out.println("Succeed !");
}
});
upload.addListener(new Upload.StartedListener() {
private static final long serialVersionUID = 1L;
public void uploadStarted(StartedEvent event) {
System.out.println("Start !");
}
});
upload.addListener(new Upload.ProgressListener() {
private static final long serialVersionUID = 1L;
public void updateProgress(long readBytes, long contentLength) {
System.out.println("Progress !");
}
});
upload.addListener(new Upload.FailedListener() {
private static final long serialVersionUID = 1L;
public void uploadFailed(FailedEvent event) {
System.out.println("Failed !");
}
});
}
public static class MyReceiver implements Receiver {
private static final long serialVersionUID = 1L;
private String fileName;
private ByteArrayOutputStream bos;
public ByteArrayOutputStream getBos() {
return bos;
}
public String getFileName(){
return fileName;
}
public ByteArrayOutputStream receiveUpload(String filename, String mimetype) {
fileName=filename;
System.out.println("new file being uploaded");
bos = new ByteArrayOutputStream(){
@Override
public void write(int b) {}
};
return bos;
}
}