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

Advanced Web Application Topics

ordinates relative to the wrapper. Notice that the coordinates are really the position of the wrapper, not the wrapped component; the wrapper reserves some space for the accept indicators.

The verticalDropLocation() and horizontalDropLocation() return the more detailed drop location in the target.

11.11.7. Dragging Files from Outside the Browser

The DragAndDropWrapper allows dragging files from outside the browser and dropping them on a component wrapped in the wrapper. Dropped files are automatically uploaded to the application and can be acquired from the wrapper with getFiles(). The files are represented as Html5File objects as defined in the inner class. You can define an upload Receiver to receive the content of a file to an OutputStream.

Dragging and dropping files to browser is supported in HTML 5 and requires a compatible browser, such as Mozilla Firefox 3.6 or newer.

11.12. Logging

You can do logging in Vaadin application using the standard java.util.logging facilities. Configuring logging is as easy as putting a file named logging.properties in the default package of your Vaadin application (src in an Eclipse project or src/main/java or src/main/resources in a Maven project). This file is read by the Logger class when a new instance of it is initialize.

Logging in Apache Tomcat

For logging Vaadin applications deployed in Apache Tomcat, you do not need to do anything special to log to the same place as Tomcat itself. If you need to write the Vaadin application related messages elsewhere, just add a custom logging.properties file to the default package of your Vaadin application.

If you would like to pipe the log messages through another logging solution, see the section called “Piping to Log4j using SLF4J” below.

Logging in Liferay

Liferay mutes logging through java.util.logging by default. In order to enable logging, you need to add a logging.properties file of your own to the default package of your Vaadin application. This file should define at least one destination where to save the log messages.

You can also log through SLF4J, which is used in and bundled with Liferay. Follow the instructions in the section called “Piping to Log4j using SLF4J”.

Piping to Log4j using SLF4J

Piping output from java.util.logging to Log4j is easy with SLF4J (http://slf4j.org/). The basic way to go about this is to add the SLF4J JAR file as well as the jul-to-slf4j.jar file, which implements the bridge from java.util.logging, to SLF4J. You will also need to add a third logging implementation JAR file, that is, slf4j-log4j12-x.x.x.jar, to log the actual messages using Log4j. For more info on this, please visit the SLF4J site.

In order to get the java.util.logging to SLF4J bridge installed, you need to add the following snippet of code to your Application class at the very top:

312

Dragging Files from Outside the Browser

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