public static Map buildTrueFalse(Locale locale) { LabelUtil label = LabelUtil.getInstance(); label.setLocale(locale); Map env = new HashMap(); env.put(new Integer(1).intValue(), label.getText("label.generic.yes")); env.put(new Integer(0).intValue(), label.getText("label.generic.no")); return env; }
public String execute(HttpServletRequest request) throws Exception { Customer customer = null; if (!validateCustomerLogon(request)) { LabelUtil l = LabelUtil.getInstance(); Locale locale = LocaleUtil.getLocale(request); l.setLocale(locale); MessageUtil.addErrorMessage(request, l.getText(locale, "login.invalid")); return "redirect:/home.html"; } try { CustomerLogonModule logon = (CustomerLogonModule) com.salesmanager.core.util.SpringUtil.getBean("customerLogon"); // get merchantId int merchantId = 1; HttpSession session = request.getSession(); MerchantStore store = (MerchantStore) session.getAttribute("STORE"); if (store != null) { merchantId = store.getMerchantId(); } customer = logon.logon(request, merchantId); if (customer == null) { MessageUtil.addErrorMessage(request, super.getText(request, "login.invalid")); return "redirect:/home.html"; } Locale locale = LocaleUtil.getLocale(request); customer.setLocale(locale); // get CustomerInfo CustomerService cservice = (CustomerService) ServiceFactory.getService(ServiceFactory.CustomerService); CustomerInfo customerInfo = cservice.findCustomerInfoById(customer.getCustomerId()); if (customerInfo == null) { customerInfo = new CustomerInfo(); customerInfo.setCustomerInfoId(customer.getCustomerId()); } Integer login = customerInfo.getCustomerInfoNumberOfLogon(); login = login + 1; customerInfo.setCustomerInfoNumberOfLogon(login); cservice.saveOrUpdateCustomerInfo(customerInfo); SessionUtil.setCustomer(customer, request); request.setAttribute("CUSTOMER", customer); return "redirect:/profile/profile.html"; } catch (ServiceException e) { MessageUtil.addErrorMessage(request, super.getText(request, "login.invalid")); return "redirect:/home.html"; } catch (Exception ex) { log.error(ex); throw ex; } }