How to get VaadinResponse in UI


In the init method of UI, we can get VaadnRequest as a parameter. I am wondering whether we can get VaadinResponse in the init method? and How? I need to have that for further processing.

Many thanks,

In Vaadin Framework 8.1 (starting from 8.1.0.rc2), there are methods VaadinRequest.getCurrent(), VaadinResponse.getCurrent(), VaadinServletRequest.getCurrent() and VaadinServletResponse.getCurrent(). In earlier versions, you can use VaadinService.getCurrentResponse().

Note that these methods can only be used while handling a request (including in the UI init), not from a background thread.

Thank you for information. Joey