List of usage examples for com.vaadin.server VaadinSession getCurrent
public static VaadinSession getCurrent()
From source file:com.fnc.dao.UserDAO.java
public static boolean authenticateLogin(String username_, String password_) { Connection conn = DBConnection.connectToDB(); Statement stmt = null;//www . j a v a2 s . c o m ResultSet rs = null; boolean result = false; try { stmt = conn.createStatement(); rs = stmt.executeQuery("SELECT userRole FROM user_ " + "WHERE username_ = '" + username_ + "' " + "AND password_ = '" + password_ + "' "); while (rs.next()) { if (rs.getString("userRole") == null) { } else { result = true; VaadinSession.getCurrent().setAttribute("username", username_); VaadinSession.getCurrent().setAttribute("userRole", rs.getString("userRole")); } } } catch (SQLException ex) { DBErrorNotification.showLoggedErrorOnWindow(ex.toString()); Logger.getLogger(UserDAO.class.getName()).log(Level.SEVERE, null, ex); } finally { try { stmt.close(); rs.close(); conn.close(); } catch (SQLException ex) { DBErrorNotification.showLoggedErrorOnWindow(ex.toString()); Logger.getLogger(UserDAO.class.getName()).log(Level.SEVERE, null, ex); } } return result; }
From source file:com.foc.vaadin.FocWebApplication.java
License:Apache License
@Override protected void init(VaadinRequest vaadinRequest) { HttpSession httpSession = null;//from w w w . j a v a 2s .co m WrappedHttpSession wrapperHttpSession = VaadinSession.getCurrent() != null ? (WrappedHttpSession) VaadinSession.getCurrent().getSession() : null; if (wrapperHttpSession != null) { httpSession = wrapperHttpSession.getHttpSession(); } initialize(vaadinRequest, VaadinServlet.getCurrent().getServletContext(), httpSession, false); initializeGUI(vaadinRequest, VaadinServlet.getCurrent().getServletContext(), httpSession); }
From source file:com.foc.web.server.session.FocWebSession.java
License:Apache License
public WrappedSession getHttpSession() { return VaadinSession.getCurrent().getSession(); }
From source file:com.freebox.engeneering.application.system.ApplicationScope.java
License:Apache License
@Override public Object get(String name, ObjectFactory<?> objectFactory) { final VaadinSession current = VaadinSession.getCurrent(); String uiId = getCurrentUiId(); Object bean = current.getAttribute(APPLICATION_SCOPE + uiId + name); if (bean == null) { bean = objectFactory.getObject(); current.setAttribute(APPLICATION_SCOPE + uiId + name, bean); }/*w ww . jav a 2s . co m*/ return bean; }
From source file:com.freebox.engeneering.application.system.ApplicationScope.java
License:Apache License
@Override public Object remove(String name) { final VaadinSession current = VaadinSession.getCurrent(); String uiId = getCurrentUiId(); Object bean = current.getAttribute(APPLICATION_SCOPE + uiId + name); if (bean != null) { current.setAttribute(APPLICATION_SCOPE + uiId + name, null); this.destructionCallbacks.remove(name); }//from w ww. j a v a2s. co m return bean; }
From source file:com.freebox.engeneering.application.system.ApplicationScope.java
License:Apache License
private String getCurrentUiId() { final UI currentUI = UI.getCurrent(); String uiId;//from ww w . jav a 2 s . c o m if (currentUI == null || currentUI.getUIId() == -1l) { uiId = VaadinSession.getCurrent().getAttribute("applicationScope.UiId").toString(); } else { uiId = currentUI.getUIId() + ""; } return uiId; }
From source file:com.freebox.engeneering.application.web.common.AbstractController.java
License:Apache License
public String getFreeboxTokenSession() { final VaadinSession current = VaadinSession.getCurrent(); String tokenSession = (String) current.getAttribute(FREEBOX_TOKEN_SESSION); return tokenSession; }
From source file:com.freebox.engeneering.application.web.common.ApplicationUIProvider.java
License:Apache License
@Override public UI createInstance(UICreateEvent event) { VaadinRequest request = event.getRequest(); Object uiBeanNameObj = request.getService().getDeploymentConfiguration() .getApplicationOrSystemProperty("UIBean", null); //Stored in VaadinSession to use it in // the ApplicationScope later to initialize vaadin application scope beans final Integer uiId = event.getUiId(); VaadinSession.getCurrent().setAttribute("applicationScope.UiId", uiId); if (uiBeanNameObj instanceof String) { String uiBeanName = uiBeanNameObj.toString(); return (UI) ApplicationContextLocator.getBean(uiBeanName); }/*from w ww.j av a 2 s .co m*/ return super.createInstance(event); }
From source file:com.github.daytron.twaattin.presenter.LoginBehaviour.java
License:Open Source License
@Override public void buttonClick(Button.ClickEvent event) { try {/*from w ww. j ava 2 s .c o m*/ String pin = loginField.getValue(); Principal user = new TwitterAuthenticationStrategy().authenticate(pin); VaadinSession.getCurrent().setAttribute(Principal.class, user); TimelineScreen aTimelineScreen = new TimelineScreen(); UI.getCurrent().setContent(aTimelineScreen); Notification authenticatedNotification = new Notification("You're now authenticated to Twaattin!", Notification.Type.TRAY_NOTIFICATION); authenticatedNotification.setPosition(Position.TOP_CENTER); authenticatedNotification.show(Page.getCurrent()); } catch (AuthenticationException e) { Notification errorNotification = new Notification(e.getMessage(), "Cick this box to close.", Notification.Type.ERROR_MESSAGE); errorNotification.show(Page.getCurrent()); } }
From source file:com.github.daytron.twaattin.presenter.LogoutBehaviour.java
License:Open Source License
@Override public void buttonClick(Button.ClickEvent event) { VaadinSession.getCurrent().setAttribute(Principal.class, null); UI.getCurrent().setContent(new LoginScreen()); Notification logoutNotification = new Notification("You've been logout", Notification.Type.TRAY_NOTIFICATION); logoutNotification.setPosition(Position.TOP_CENTER); logoutNotification.show(Page.getCurrent()); }