Forums de discussion

file upload in liferay with vaadin in liferay 6

thumbnail
mokh man, modifié il y a 13 années.

file upload in liferay with vaadin in liferay 6

Junior Member Publications: 32 Date d'inscription: 27/12/07 Publications récentes
hi
i am trying to write a portlet that handle file uploading with vaadin.
in my code add file upload component done correctly but when i click upload button then don't enter in "receiveUpload" method to i do other tasks.
my code in the below:





public class AddressBookApplication extends Application
{
private Window main = new Window("test");

public void init() {
setMainWindow(main);
}
private Label result = new Label();

private LineBreakCounter counter = new LineBreakCounter();

private Upload upload = new Upload("Upload a file", counter);

public AddressBookApplication() {
main.addComponent(upload);
main.addComponent(result);
upload.addListener(new Upload.FinishedListener() {
public void uploadFinished(FinishedEvent event) {
result.setValue("Uploaded file contained "
+ counter.getLineBreakCount() + " linebreaks");
}
});

}

public static class LineBreakCounter implements Receiver {

private String fileName;
private String mtype;
private int counter;

/**
* return an OutputStream that simply counts lineends
*/
public OutputStream receiveUpload(String filename, String MIMEType) {
// this line because of i know that enter in this method
System.out.println("AddressBookApplication$LineBreakCounter.receiveUpload");
counter = 0;
fileName = filename;
mtype = MIMEType;
return new OutputStream() {
private static final int searchedByte = '\n';

@Override
public void write(int b) throws IOException {
if (b == searchedByte) {
counter++;
}
}
};
}

public String getFileName() {
return fileName;
}

public String getMimeType() {
return mtype;
}

public int getLineBreakCount() {
return counter;
}

}

}




please help me !!!
thumbnail
mokhtar hatampoor, modifié il y a 13 années.

RE: file upload in liferay with vaadin in liferay 6

Junior Member Publications: 32 Date d'inscription: 27/12/07 Publications récentes
when i implement PortletApplicationContext2.PortletListener then after i click upload button, handleActionRequest called instead of receiveUpload method.
how i relate this two method that i access file that user upload.