/** * Gets the currently processed Vaadin portlet response. The current * response is automatically defined when the request is started. The * current response can not be used in e.g. background threads because of * the way server implementations reuse response instances. * * @return the current Vaadin portlet response instance if available, * otherwise <code>null</code> * */ public static VaadinPortletResponse getCurrentResponse() { return (VaadinPortletResponse) VaadinService.getCurrentResponse(); }
public static VaadinServletResponse getCurrentResponse() { return (VaadinServletResponse) VaadinService.getCurrentResponse(); }
private void setCookies() { if (multiTenancyIndicator.isMultiTenancySupported()) { final Cookie tenantCookie = new Cookie(SP_LOGIN_TENANT, tenant.getValue().toUpperCase()); tenantCookie.setPath("/"); // 100 days tenantCookie.setMaxAge(HUNDRED_DAYS_IN_SECONDS); tenantCookie.setHttpOnly(true); tenantCookie.setSecure(uiProperties.getLogin().getCookie().isSecure()); VaadinService.getCurrentResponse().addCookie(tenantCookie); } final Cookie usernameCookie = new Cookie(SP_LOGIN_USER, username.getValue()); usernameCookie.setPath("/"); // 100 days usernameCookie.setMaxAge(HUNDRED_DAYS_IN_SECONDS); usernameCookie.setHttpOnly(true); usernameCookie.setSecure(uiProperties.getLogin().getCookie().isSecure()); VaadinService.getCurrentResponse().addCookie(usernameCookie); }
private void setCookies() { if (multiTenancyIndicator.isMultiTenancySupported()) { final Cookie tenantCookie = new Cookie(SP_LOGIN_TENANT, tenant.getValue().toUpperCase()); tenantCookie.setPath("/"); // 100 days tenantCookie.setMaxAge(HUNDRED_DAYS_IN_SECONDS); tenantCookie.setHttpOnly(true); tenantCookie.setSecure(uiProperties.getLogin().getCookie().isSecure()); VaadinService.getCurrentResponse().addCookie(tenantCookie); } final Cookie usernameCookie = new Cookie(SP_LOGIN_USER, username.getValue()); usernameCookie.setPath("/"); // 100 days usernameCookie.setMaxAge(HUNDRED_DAYS_IN_SECONDS); usernameCookie.setHttpOnly(true); usernameCookie.setSecure(uiProperties.getLogin().getCookie().isSecure()); VaadinService.getCurrentResponse().addCookie(usernameCookie); }
VaadinResponse response = VaadinService.getCurrentResponse(); if (response != null) { response.setStatus(404);
protected void redirectAfterLogout(String loggedOutUrl) { if (!Strings.isNullOrEmpty(loggedOutUrl)) { AppUI currentUi = AppUI.getCurrent(); // it can be null if we handle request in a custom RequestHandler if (currentUi != null) { currentUi.setContent(null); currentUi.getPage().setLocation(loggedOutUrl); } else { VaadinResponse response = VaadinService.getCurrentResponse(); try { ((VaadinServletResponse) response).getHttpServletResponse(). sendRedirect(loggedOutUrl); } catch (IOException e) { log.error("Error on send redirect to client", e); } } VaadinSession vaadinSession = VaadinSession.getCurrent(); for (UI ui : vaadinSession.getUIs()) { if (ui != currentUi) { ui.access(() -> { ui.setContent(null); ui.getPage().setLocation(loggedOutUrl); }); } } } }
ou, (VaadinServletRequest)(VaadinService.getCurrentRequest()), (VaadinServletResponse)(VaadinService.getCurrentResponse())); VaadinService.getCurrentRequest().getWrappedSession().setAttribute( CmsWorkplaceManager.SESSION_WORKPLACE_SETTINGS,