Beispiel #1
0
  /** Simple event to set the users per-session currency uom value */
  public static String setSessionCurrencyUom(
      HttpServletRequest request, HttpServletResponse response) {
    String currencyUom = request.getParameter("currencyUom");
    if (UtilValidate.isNotEmpty(currencyUom)) {
      // update the session
      UtilHttp.setCurrencyUom(request.getSession(), currencyUom);

      // update the UserLogin object
      GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");
      if (userLogin == null) {
        userLogin = (GenericValue) request.getSession().getAttribute("autoUserLogin");
      }

      if (userLogin != null) {
        GenericValue ulUpdate = GenericValue.create(userLogin);
        ulUpdate.set("lastCurrencyUom", currencyUom);
        try {
          ulUpdate.store();
          userLogin.refreshFromCache();
        } catch (GenericEntityException e) {
          Debug.logWarning(e, module);
        }
      }
    }
    return "success";
  }