powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Java [игнор отключен] [закрыт для гостей] / vaadin TableExport
3 сообщений из 3, страница 1 из 1
vaadin TableExport
    #37607111
ferc
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Здравствуйте,
к vaadin есть аддон TableExport для экспорта таблиц в эксель, так вот он оставляет tmp файлы на сервере кто-нибудь знает как его от этого отучить?
...
Рейтинг: 0 / 0
vaadin TableExport
    #37618320
ferc
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
нашел почему...

вот в этом методе не был закрыт поток
Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
/**
     * Export the workbook to the end-user.
     * 
     * Code obtained from: http://vaadin.com/forum/-/message_boards/view_message/159583
     * 
     * @return true, if successful
     */
    @Override
    public boolean sendConverted() {
        File tempFile;
        try {
            tempFile = File.createTempFile("tmp", ".xls");
            final FileOutputStream fileOut = new FileOutputStream(tempFile);
            workbook.write(fileOut);
            if (null == mimeType) {
                setMimeType(EXCEL_MIME_TYPE);
            }
            fileOut.flush(); // тут
            fileOut.close(); //тут
            return super.sendConvertedFileToUser(table.getApplication(), tempFile, exportFileName);
        } catch (final IOException e) {
            return false;
        }
    }



из-за этого файл не удалялся вот здесь

Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
package com.vaadin.addon.tableexport;

import java.io.*;

/**
 * This input stream deletes the given file when the InputStream is closed; intended to be used with
 * temporary files.
 *
 * Code obtained from: http://vaadin.com/forum/-/message_boards/view_message/159583
 *
 */
class DeletingFileInputStream extends FileInputStream implements Serializable{

    /** The file. */
    protected File file = null;

    /**
     * Instantiates a new deleting file input stream.
     *
     * @param file
     *            the file
     * @throws FileNotFoundException
     *             the file not found exception
     */
    public DeletingFileInputStream(final File file) throws FileNotFoundException {
        super(file);
        this.file = file;
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.io.FileInputStream#close()
     */
    @Override
    public void close() throws IOException {
        super.close();
        file.delete(); //тут

    }
}
...
Рейтинг: 0 / 0
vaadin TableExport
    #37618340
ferc
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
есть еще один вопрос по этому же аддону.
при нажатии на кнопку портится адресная строка, как избавиться от этого?
например,
строка была:
http://localhost:8080/WAS/NIO/SVP/index.jsp?home=http%3a%2f%2flocalhost%3a8080%2fWAS%2fNIO%2f
после нажатия на кнопку стала:
http://localhost:8080/WAS/NIO/SVP/index.jsp/APP/1/outReport.xls

на кнопке весит вызов аддона:

Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
import com.vaadin.ui.Table;

private Table toExcel;
...
                ExcelExport excelExport = new ExcelExport(toExcel,"report");

                excelExport.excludeCollapsedColumns();
                excelExport.setDisplayTotals(false);
                excelExport.setExportFileName("outReport.xls");

                excelExport.export();
...
Рейтинг: 0 / 0
3 сообщений из 3, страница 1 из 1
Форумы / Java [игнор отключен] [закрыт для гостей] / vaadin TableExport
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]