Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
book-of-vaadin.pdf
Скачиваний:
88
Добавлен:
24.03.2015
Размер:
13.43 Mб
Скачать

Advanced Web Application Topics

new MyPdfSource((String) name.getValue());

//Create the stream resource and give it a file name String filename = "pdf_printing_example.pdf"; StreamResource resource =

new StreamResource(source, filename);

//These settings are not usually necessary. MIME type

//is detected automatically from the file name, but

//setting it explicitly may be necessary if the file

//suffix is not ".pdf". resource.setMIMEType("application/pdf"); resource.getStream().setParameter(

"Content-Disposition", "attachment; filename="+filename);

//Extend the print button with an opener

//for the PDF resource

BrowserWindowOpener opener =

new BrowserWindowOpener(resource); opener.extend(print);

name.setEnabled(false);

ok.setEnabled(false);

print.setEnabled(true);

}

});

layout.addComponent(name);

layout.addComponent(ok);

layout.addComponent(print);

11.7. Google App Engine Integration

Vaadin includes support to run Vaadin applications in the Google App Engine (GAE). The most essential requirement for GAE is the ability to serialize the application state. Vaadin applications are serializable through the java.io.Serializable interface.

To run as a GAE application, an application must use GAEApplicationServlet instead of ApplicationServlet in web.xml, and of course implement the java.io.Serializable interface for all persistent classes. You also need to enable session support in appengine-web.xml with:

<sessions-enabled>true</sessions-enabled>

The Vaadin Project wizard can create the configuration files needed for GAE deployment. See Section 2.5.1, “Creating the Project”. When the Google App Engine deployment configuration is selected, the wizard will create the project structure following the GAE Servlet convention instead of the regular Servlet convention. The main differences are:

Source directory: src/main/java

Output directory: war/WEB-INF/classes

Content directory: war

Rules and Limitations

Running Vaadin applications in Google App Engine has the following rules and limitations:

Avoid using the session for storage, usual App Engine limitations apply (no synchronization, that is, it is unreliable).

296

Google App Engine Integration

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]