Esempio n. 1
0
  @Override
  public void enter(ViewChangeEvent event) {
    if (((MyUI) UI.getCurrent()).getLogged() == false) {
      getUI().getNavigator().navigateTo(MyUI.LOGIN_USER);
    }

    ((MyUI) UI.getCurrent()).setLogged(false);
    ((MyUI) UI.getCurrent()).setUserLogin(null);
    ((MyUI) UI.getCurrent()).setUserPass(null);
    ((MyUI) UI.getCurrent()).setUserId(-1);

    {
      Cookie newCookie = new Cookie("userLogin", "");
      newCookie.setComment("userLogin user");
      newCookie.setMaxAge(0);
      newCookie.setPath("/");
      VaadinService.getCurrentResponse().addCookie(newCookie);
      newCookie = new Cookie("userPass", "");
      newCookie.setComment("pass user");
      newCookie.setMaxAge(0);
      newCookie.setPath("/");
      VaadinService.getCurrentResponse().addCookie(newCookie);
      newCookie = new Cookie("userId", "");
      newCookie.setComment("id user");
      newCookie.setMaxAge(0);
      newCookie.setPath("/");
      VaadinService.getCurrentResponse().addCookie(newCookie);
    }

    getUI().getNavigator().navigateTo(MyUI.MAIN);
  }
  @Override
  public void sessionInit(SessionInitEvent event) throws ServiceException {
    // event.getSession().setErrorHandler(new UIErrorHandler());
    Cookie langCookie = null;
    if (event.getRequest() != null) {
      for (Cookie cookie : event.getRequest().getCookies())
        if (cookie.getName().equals(VWebCommonConstants.USER_LANGUAGE_APPCOOKIE)) {
          langCookie = cookie;
          break;
        }
    }

    if (langCookie == null) langCookie = createLanguageCookie(event.getRequest());
    event.getSession().setLocale(LocaleUtils.toLocale(langCookie.getValue()));
    VaadinService.getCurrentResponse().addCookie(langCookie);
  }