Пример #1
0
  public void sendOffer() {
    Trade trade = new Trade();
    if (handtohand == true) {
      trade.setStatus("handtohand");
    } else {
      trade.setStatus("opened");
    }
    trade.setOfferingUser(userService.getUserById(SessionBean.getUserId()));
    trade.setReceivingUser(userService.getUserById(SessionBean.getUserForTradeId()));
    trade.setOfferingUserPay(false);
    trade.setReceivingUserPay(false);
    trade.setReceivedByOfferingUser(false);
    trade.setReceivedByReceivingUser(false);
    trade.setDeposit(deposit);
    tradeService.create(trade);
    Trade currentTrade = tradeService.getLastTradeByOfferingUserId(SessionBean.getUserId());
    for (Game g : myGames.getTarget()) {
      OfferingUserTrade out = new OfferingUserTrade();
      out.setOfferingGame(g);
      out.setOfferingTrade(currentTrade);
      offeringUserTradeService.create(out);
    }

    for (Game g : tradeUserGames.getTarget()) {
      ReceivingUserTrade rut = new ReceivingUserTrade();
      rut.setReceivingGame(g);
      rut.setReceivingTrade(currentTrade);
      receivingUserTradeService.create(rut);
    }

    SessionBean.getSession().removeAttribute("tradeuser");
    RequestContext.getCurrentInstance().closeDialog("tradeOffer");
    FacesContext.getCurrentInstance()
        .addMessage(null, new FacesMessage("Trade offer has been sent"));
  }
Пример #2
0
 public void openOfferDialog(User u) {
   SessionBean.getSession().setAttribute("tradeuser", u.getId());
   Map<String, Object> options = new HashMap<String, Object>();
   options.put("resizable", false);
   options.put("draggable", false);
   options.put("contentWidth", 1400);
   options.put("contentHeight", 800);
   options.put("modal", true);
   RequestContext.getCurrentInstance().openDialog("tradeOffer", options, null);
 }
  public String login() {
    int userId = UserHandler.loginUser(username, password);

    if (userId > -1) {
      setLoggedIn(true);

      HttpSession session = SessionBean.getSession();

      session.setAttribute("userId", userId);
      session.setAttribute("username", username);

      return "timeline.xhtml";
    }

    return "index.xhtml";
  }
  public boolean isLoggedIn() {
    HttpSession session = SessionBean.getSession();

    if (session != null) {
      System.out.println("session");
      String user = (String) session.getAttribute("username");
      if (user != null) {
        System.out.println("user");
        System.out.println("LoginBean: found session");
        System.out.println("LoginBean: session username = "******"username"));
        return true;
      }
    }

    System.out.println("LoginBean: didn't find session");
    return false;
  }
  public String logout() {
    HttpSession session = SessionBean.getSession();

    session.invalidate();
    return "login";
  }