Package com.ateam.webstore.ui.forms

Examples of com.ateam.webstore.ui.forms.FormSubmission


   * @param submission
   * @return
   */
  public FormSubmission processOrderConfirmationRequest() {
   
    FormSubmission submission = new FormSubmission();
       
    Orders order = (Orders) req.getSession().getAttribute(SESSION_ATTRIBUTE_ORDER);
    Collection<ItemsOrdered> items = (Collection<ItemsOrdered>) req.getSession().getAttribute(SESSION_ATTRIBUTE_ORDERED_ITEMS);
   
    try {
      order = service.store(order);
      l.info("order "+order.getId()+" created");
      ItemsOrderedService is = new ItemsOrderedService();
      for (ItemsOrdered item : items) {
        item.setOrders(order);
        is.store(item);
        l.info("item "+item.getProduct().getId()+" added to order");
      }
     
      submission.setResultMessage("Order Placed!");
     
      CartHandler ch = new CartHandler(req);
      ch.delete();

    } catch (Exception e) {
      l.log(Level.WARNING, "Failed to store order.", e);
      submission.setResultMessage("Failed to submit order");
    }
   
    submission.setResultView(getOrderDetailsView(order,false));
   
    return submission;
  }
View Full Code Here


//   
//    return odv;
//  }

  public FormSubmission processOrderUpdateRequest() {
    FormSubmission fs = new FormSubmission();
   
    l.info("order update");
   
    Orders o = getOrder();
   
    String action = req.getParameter(Parameters.ORDER_CONFIRM.getId());
   
    if (action.equals("Update Order")) {
     
      if (req.getParameter(Parameters.TRACKING_NUMBER.getId()) != null) {
        o.setTrackingNumber(req.getParameter(Parameters.TRACKING_NUMBER.getId()));
        o.setTimeShipped(new Date(new java.util.Date().getTime()));
        fs.setResultMessage("Order Updated");
      }
      else {
        fs.setResultMessage("Invalid Tracking Number");
        fs.setResultView(getOrderDetailsView(null, true));
        return fs;
      }
     
    }
    else if (action.equals("Cancel Order")) {
      o.setReturnInd(true);
      fs.setResultMessage("Order Cannceled");
    }
   
    fs.setResultView(getOrderDetailsView(null, true));
    service.store(o);
   
    return fs;
  }
View Full Code Here

  /**
   * Submit a new service case
   * @return
   */
  public FormSubmission submitNewCase() {
    FormSubmission fs = new FormSubmission();

    String message = req.getParameter(Parameters.MESSAGE.getId());
   
    if (fs.validString(message)) {
      Visitor v = (Visitor) req.getSession().getAttribute(SESSION_ATTRIBUTE_VISITOR);
     
     
      try {
        Customer person = v.getCustomer();
       
        ServiceCase scase = new ServiceCase(person);
        service.store(scase);
       
        MessageService ms = new MessageService();
       
        Message mess = new Message(scase, person.getPerson(), false, 0, message);
        ms.store(mess);
        fs.setResultMessage("Feedback sent.");
       
        fs.setResultView(getMessageView("Feedback Sent.", "Send Feedback"));
       
      } catch (Exception e) {
        l.log(Level.WARNING, "Failed to store feedback", e);
        fs.setResultMessage("Failed to send feedback.");
        fs.setResultView(getFeedbackView());
      }
     
    }
   
    else {
      fs.setResultMessage("Invalid Message Text");
      fs.setResultView(getFeedbackView());
    }
   
   
    return fs;
  }
View Full Code Here



    public FormSubmission processDeleteEmployeeRequest() {
     
      FormSubmission fs = new FormSubmission();
     
      fs.setResultView(getEmployeeListView());
      try {
        Employee e = getEmployee();
        service.remove(e);
        fs.setResultMessage("Employee deleted");
      } catch (Exception e) {
        fs.setResultMessage("Failed to delete employee");
        l.log(Level.WARNING, "Failed to delete eomplyee", e);
      }
     
      return fs;
     
View Full Code Here

    View v = null;
   
    try {
     
      //Get the form and process
      FormSubmission results = processFormSubmission(req);
     
      v = results.getResultView();

      v.setServletPath("store");
      req.setAttribute(REQUEST_ATTRIBUTE_VIEW, v);

      l.info(req.getAttribute(REQUEST_ATTRIBUTE_VIEW).toString());
View Full Code Here

   
   
    try {
     
      //Get the form and process
      FormSubmission results = processFormSubmission(req);
     
      //Set Result View
      View v = results.getResultView();
      v.setServletPath("admin");
      req.setAttribute(REQUEST_ATTRIBUTE_VIEW, results.getResultView());

      l.info(req.getAttribute(REQUEST_ATTRIBUTE_VIEW).toString());
     
      //Forward to JSP
      getServletConfig().getServletContext().getRequestDispatcher(
View Full Code Here

    return v;
  }

  public FormSubmission processPasswordRecovery() {

    FormSubmission fs = new FormSubmission();
   
    String email = req.getParameter(Parameters.EMAIL.getId());
    if (service.customerExists(email)) {
      //fs .setResultMessage();
      l.info("password recovery sent for "+email);
      fs.setResultView(getMessageView("Request Sent. You will recieve instructions to reset your password.", "Password Recovery"));
    }
    else {
      fs.setResultView(getMessageView("No account exists for "+email, "Password Recovery"));
    }

    fs.getResultView().setShowLogonForm(false);
   
    return fs;
  }
View Full Code Here

   * Add a product to the users cart
   * @return
   */
  public FormSubmission addProduct(String prodId) {
   
    FormSubmission add = new FormSubmission();
   
    //Check auth
    Visitor v = (Visitor) req.getSession().getAttribute(SESSION_ATTRIBUTE_VISITOR);
   
    if (prodId == null) {
      prodId = req.getParameter(Parameters.PRODUCT_ID.getId());
    }
   
    req.getSession().setAttribute(SESSION_ATTRIBUTE_PRODUCT_TO_CART, prodId);
   
    if (v == null || !v.isAuthenticated()) {
      l.info("not authenticated for product add ");
      CustomerHandler ch = new CustomerHandler(req);
      add.setResultView(ch.getLoginView());
      add.setResultMessage("Please first login");
      return add;
    }
   
    if (cart == null) {
      l.info("creating cart for session: "+req.getSession().getId());
      Customer cust = v.getCustomer();
      cart = new Cart(cust);
      service.store(cart);
      req.getSession().setAttribute(SESSION_ATTRIBUTE_CART, service.getByCustomerId(cust.getId()));
    }

    l.info("adding product to cart for session: "+req.getSession().getId());

    l.fine("add prodId :"+prodId);   

    ProductsInCart prodInCart = new ProductsInCart(1, cart, new ProductService().getById(new Long(prodId)));
    cart.addProduct(prodInCart);
    service.store(cart);
   
    add.setResultView(getCartView());
   
    return add;
  }
View Full Code Here

  public FormSubmission processUpdate() {
   
    l.info("modifying cart for session: "+req.getSession().getId());
   
    FormSubmission fs = new FormSubmission();
   
    try {
      String action = req.getParameter(Parameters.CART_ACTION.getId());
     
      if (action.equals("Checkout")) {
        fs.setResultView(checkout());
      }
      else if (action.equals("Move Selected to WishList")) {
        fs = moveSelectedToWishList();
      }
      else if (action.equals("Update Quantity")) {
        for (Enumeration e = req.getParameterNames() ; e.hasMoreElements() ;) {
          String name = (String) e.nextElement();
          if (name.endsWith(Constants.Parameters.PRODUCT_QUANTITY.getId())) {
            String[] parts = name.split("_");
            Integer quantity = Integer.parseInt(req.getParameter(name));           
            String id = parts[0];
            l.fine("updating qty for "+id);
            ProductsInCartService pics = new ProductsInCartService();
            ProductsInCart pic = pics.getById(new Long(id));
           
            if (quantity == 0) {
              pics.remove(pic);             
            }
            else {
              pic.setQuantity(quantity);
              pics.store(pic);
            }
          }
        }
        updateCart();
        fs.setResultView(getCartView());     
      }
    } catch (Exception e) {
      l.log(Level.WARNING, "Unable to process cart update", e);
      View v = getCartView();
      v.setMessage("Unable to process request.");
      fs.setResultView(v);
      fs.setResultMessage("Unable to process request.");
    }


   
    return fs;
View Full Code Here

 
  public FormSubmission moveSelectedToWishList() {

    WishListHandler wlh = new WishListHandler(req);
    ProductsInCartService pics = new ProductsInCartService();
    FormSubmission fs = new FormSubmission();
   
    int i = 0;
   
    for (ProductsInCart p : cart.getProducts()) {
      String prodId = p.getProduct().getId()+"";
      if (req.getParameter(prodId) != null) {
        l.fine("moving prodId :"+prodId+" to wish list");
        wlh.addProduct(prodId);
        pics.remove(p);
        i++;
      }
    }
   
    if (i > 0) {
      fs.setResultView(wlh.getWishListView())
      fs.setResultMessage(i+" products moved to your wish list.");
    }
    else {
      fs.setResultView(getCartView())
      fs.setResultMessage("No products were selected");
    }

    return fs;
  }
View Full Code Here

TOP

Related Classes of com.ateam.webstore.ui.forms.FormSubmission

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.