コード例 #1
0
  public void logout(Screen s, JSONObject data) {
    s.setProperty("username", "");
    s.setProperty("lastlogin", "0");

    JSONObject logout = new JSONObject();
    logout.put("function", "logout");
    logout.put("arguments", "");

    screen.get(selector).update(logout);
  }
コード例 #2
0
  public void onNewScreen(Screen s) {
    s.setLanguageCode("en");

    String username = (String) s.getProperty("username");
    String lastVisit = (String) s.getProperty("lastlogin");
    long lastLogin = Long.MIN_VALUE;
    System.out.println("username " + username + " lastLogin " + lastVisit);
    if (lastVisit != null) {
      lastLogin = Long.parseLong(lastVisit);
    }

    loadStyleSheet(s, "desktop");

    if (username != null
        && lastVisit != null
        && (new Date().getTime() - lastLogin < MAX_SESSION_TIME)) {
      s.get("#screen").setViewProperty("template", "screen.mst");
      // attach all the controllers for this view from app.xml
      s.get("#screen").attach(new ScreenController());
      HeaderController header = new HeaderController();
      s.get("#header").attach(header);
      s.bind("#header", "client", "logout", header);
      s.get("#workflowbar").attach(new WorkflowController());
      s.get("#workarea").attach(new WorkAreaController());
    } else {
      s.get("#screen").setViewProperty("template", "login/index.mst");
      // attach all the controllers for this view from app.xml
      s.get("#screen").attach(new ScreenController());
      LoginController login = new LoginController();
      s.get("#login").attach(login);
      s.bind("#login", "client", "loginSubmitted", login);
    }
  }