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

Writing a Server-Side Web Application

Widget sets (OPTIONAL)

If your application uses a project-specific widget set, it must be compiled in the

VAADIN/widgetset/ directory.

4.8.3. Deployment Descriptor web.xml

The deployment descriptor is an XML file with the name web.xml in the WEB-INF directory of a web application. It is a standard component in Java EE describing how a web application should be deployed. The descriptor is not needed with Servlet API 3.0, where you can define servlets also as web fragments, with the @WebServlet annotation, or programmatically.

The following example illustrates the structure of a deployment descriptor. You simply specify the UI class with the UI parameter for the com.vaadin.server.VaadinServlet. The servlet is then mapped to a URL path in a standard way for Java Servlets.

<?xml version="1.0" encoding="UTF-8"?> <web-app

id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee

http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

<servlet> <servlet-name>myservlet</servlet-name> <servlet-class>

com.vaadin.server.VaadinServlet </servlet-class>

<init-param> <param-name>UI</param-name>

<param-value>com.ex.myprj.MyUI</param-value> </init-param>

<!-- If not using the default widget set--> <init-param>

<param-name>widgetset</param-name> <param-value>com.ex.myprj.MyWidgetSet</param-value>

</init-param> </servlet>

<servlet-mapping> <servlet-name>myservlet</servlet-name> <url-pattern>/*</url-pattern>

</servlet-mapping> </web-app>

The descriptor defines a servlet with the name myservlet.The servlet class, com.vaadin.server.VaadinServlet, is provided by Vaadin framework and is normally the same for all Vaadin projects. For some purposes, you may need to use a custom servlet class.

Widget Set

If the UI uses add-on components or custom widgets, it needs a custom widget set, which is specified with the widgetset parameter for the servlet. The parameter is a class name with the same path but without the .gwt.xml extension as the widget set definition file. If the parameter is not given, the com.vaadin.DefaultWidgetSet is used, which contains all the widgets for the built-in Vaadin components.

84

Deployment Descriptor web.xml

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