Package org.springframework.samples.jpetstore.domain

Examples of org.springframework.samples.jpetstore.domain.Account


    this.account = account;
    this.newAccount = false;
  }

  public AccountForm() {
    this.account = new Account();
    this.newAccount = true;
  }
View Full Code Here


  }

  public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
    String username = request.getParameter("username");
    String password = request.getParameter("password");
    Account account = this.petStore.getAccount(username, password);
    if (account == null) {
      return new ModelAndView("Error", "message", "Invalid username or password.  Signon failed.");
    }
    else {
      UserSession userSession = new UserSession(account);
      PagedListHolder myList = new PagedListHolder(this.petStore.getProductListByCategory(account.getFavouriteCategoryId()));
      myList.setPageSize(4);
      userSession.setMyList(myList);
      request.getSession().setAttribute("userSession", userSession);
      String forwardAction = request.getParameter("forwardAction");
      if (forwardAction != null) {
View Full Code Here

  protected Object formBackingObject(HttpServletRequest request) throws ModelAndViewDefiningException {
    UserSession userSession = (UserSession) request.getSession().getAttribute("userSession");
    Cart cart = (Cart) request.getSession().getAttribute("sessionCart");
    if (cart != null) {
      // Re-read account from DB at team's request.
      Account account = this.petStore.getAccount(userSession.getAccount().getUsername());
      OrderForm orderForm = new OrderForm();
      orderForm.getOrder().initOrder(account, cart);
      return orderForm;
    }
    else {
View Full Code Here

  protected void onBindAndValidate(HttpServletRequest request, Object command, BindException errors)
      throws Exception {

    AccountForm accountForm = (AccountForm) command;
    Account account = accountForm.getAccount();

    if (request.getParameter("account.listOption") == null) {
      account.setListOption(false);
    }
    if (request.getParameter("account.bannerOption") == null) {
      account.setBannerOption(false);
    }

    errors.setNestedPath("account");
    getValidator().validate(account, errors);
    errors.setNestedPath("");

    if (accountForm.isNewAccount()) {
      account.setStatus("OK");
      ValidationUtils.rejectIfEmpty(errors, "account.username", "USER_ID_REQUIRED", "User ID is required.");
      if (account.getPassword() == null || account.getPassword().length() < 1 ||
          !account.getPassword().equals(accountForm.getRepeatedPassword())) {
       errors.reject("PASSWORD_MISMATCH",
           "Passwords did not match or were not provided. Matching passwords are required.");
      }
    }
    else if (account.getPassword() != null && account.getPassword().length() > 0) {
      if (!account.getPassword().equals(accountForm.getRepeatedPassword())) {
        errors.reject("PASSWORD_MISMATCH",
            "Passwords did not match. Matching passwords are required.");
      }
    }
   }
View Full Code Here

  protected ActionForward doExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    AccountActionForm workingAcctForm = (AccountActionForm) form;
    AccountActionForm acctForm = (AccountActionForm) request.getSession().getAttribute("accountForm");
    String username = acctForm.getAccount().getUsername();
    if (workingAcctForm.getAccount() == null) {
      Account account = getPetStore().getAccount(username);
      workingAcctForm.setAccount(account);
    }
    if (workingAcctForm.getCategories() == null) {
      List categories = getPetStore().getCategoryList();
      workingAcctForm.setCategories(categories);
View Full Code Here

    AccountActionForm acctForm = (AccountActionForm) request.getSession().getAttribute("accountForm");
    CartActionForm cartForm = (CartActionForm) request.getSession().getAttribute("cartForm");
    if (cartForm != null) {
      OrderActionForm orderForm = (OrderActionForm) form;
      // Re-read account from DB at team's request.
      Account account = getPetStore().getAccount(acctForm.getAccount().getUsername());
      orderForm.getOrder().initOrder(account, cartForm.getCart());
      return mapping.findForward("success");
    }
    else {
      request.setAttribute("message", "An order could not be created because a cart could not be found.");
View Full Code Here

  public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    AccountActionForm workingAcctForm = new AccountActionForm();
    request.getSession().removeAttribute("workingAccountForm");
    request.getSession().setAttribute("workingAccountForm", workingAcctForm);
    if (workingAcctForm.getAccount() == null) {
      workingAcctForm.setAccount(new Account());
    }
    if (workingAcctForm.getCategories() == null) {
      workingAcctForm.setCategories(getPetStore().getCategoryList());
    }
    return mapping.findForward("success");
View Full Code Here

    }
    else {
      AccountActionForm acctForm = (AccountActionForm) form;
      String username = acctForm.getUsername();
      String password = acctForm.getPassword();
      Account account = getPetStore().getAccount(username, password);
      if (account == null) {
        request.setAttribute("message", "Invalid username or password.  Signon failed.");
        return mapping.findForward("failure");
      }
      else {
        String forwardAction = acctForm.getForwardAction();
        acctForm = new AccountActionForm();
        acctForm.setForwardAction(forwardAction);
        acctForm.setAccount(account);
        acctForm.getAccount().setPassword(null);
        PagedListHolder myList = new PagedListHolder(getPetStore().getProductListByCategory(account.getFavouriteCategoryId()));
        myList.setPageSize(4);
        acctForm.setMyList(myList);
        request.getSession().setAttribute("accountForm", acctForm);
        if (acctForm.getForwardAction() == null || acctForm.getForwardAction().length() < 1) {
          return mapping.findForward("success");
View Full Code Here

  protected ActionForward doExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    AccountActionForm acctForm = (AccountActionForm) form;
    if (AccountActionForm.VALIDATE_EDIT_ACCOUNT.equals(acctForm.getValidate())) {
      acctForm.getAccount().setListOption(request.getParameter("account.listOption") != null);
      acctForm.getAccount().setBannerOption(request.getParameter("account.bannerOption") != null);
      Account account = acctForm.getAccount();
      getPetStore().updateAccount(account);
      acctForm.setAccount(getPetStore().getAccount(account.getUsername()));
      PagedListHolder myList = new PagedListHolder(getPetStore().getProductListByCategory(account.getFavouriteCategoryId()));
      myList.setPageSize(4);
      acctForm.setMyList(myList);
      request.getSession().setAttribute("accountForm", acctForm);
      request.getSession().removeAttribute("workingAccountForm");
      return mapping.findForward("success");
View Full Code Here

  public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    AccountActionForm acctForm = (AccountActionForm) form;
    if (AccountActionForm.VALIDATE_NEW_ACCOUNT.equals(acctForm.getValidate())) {
      acctForm.getAccount().setListOption(request.getParameter("account.listOption") != null);
      acctForm.getAccount().setBannerOption(request.getParameter("account.bannerOption") != null);
      Account account = acctForm.getAccount();
      String username = acctForm.getAccount().getUsername();
      getPetStore().insertAccount(account);
      acctForm.setAccount(getPetStore().getAccount(username));
      PagedListHolder myList = new PagedListHolder(getPetStore().getProductListByCategory(account.getFavouriteCategoryId()));
      myList.setPageSize(4);
      acctForm.setMyList(myList);
      request.getSession().setAttribute("accountForm", acctForm);
      request.getSession().removeAttribute("workingAccountForm");
      return mapping.findForward("success");
View Full Code Here

TOP

Related Classes of org.springframework.samples.jpetstore.domain.Account

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.